diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2013-06-16 21:15:09 +0200 |
---|---|---|
committer | Amaury Pouly <amaury.pouly@gmail.com> | 2013-06-17 00:29:25 +0200 |
commit | 52426d08918eadfba178f74e1bd5d1663f9c73e0 (patch) | |
tree | 3a9488a65d7d3f854f84615238ce174dfd956c6a /firmware/target/arm | |
parent | f4fdf1ffe2189dafd1ebbbbf50f1a4626364ead3 (diff) |
imx233: fix pinctrl for stmp3600 and stmp3700
Change-Id: I87281b89315890fa285cb9a63fda5c90bdc8cdbf
Diffstat (limited to 'firmware/target/arm')
10 files changed, 70 insertions, 69 deletions
diff --git a/firmware/target/arm/imx233/creative-zenxfi2/button-zenxfi2.c b/firmware/target/arm/imx233/creative-zenxfi2/button-zenxfi2.c index b990becf26..74b8d649b3 100644 --- a/firmware/target/arm/imx233/creative-zenxfi2/button-zenxfi2.c +++ b/firmware/target/arm/imx233/creative-zenxfi2/button-zenxfi2.c @@ -119,10 +119,9 @@ int button_read_device(int *data) int res = 0; /* B0P11: #power * B0P14: #select */ - uint32_t mask = imx233_pinctrl_get_gpio_mask(0, 0x4800); - if(!(mask & 0x800)) + if(!imx233_pinctrl_get_gpio(0, 11)) res |= BUTTON_POWER; - if(!(mask & 0x4000)) + if(!imx233_pinctrl_get_gpio(0, 14)) res |= BUTTON_MENU; return res | touchscreen_read_device(data); } diff --git a/firmware/target/arm/imx233/creative-zenxfi2/lcd-zenxfi2.c b/firmware/target/arm/imx233/creative-zenxfi2/lcd-zenxfi2.c index 1e60e60463..9ff64c4c14 100644 --- a/firmware/target/arm/imx233/creative-zenxfi2/lcd-zenxfi2.c +++ b/firmware/target/arm/imx233/creative-zenxfi2/lcd-zenxfi2.c @@ -53,7 +53,7 @@ static void setup_lcd_pins(bool use_lcdif) imx233_pinctrl_acquire(1, 23, "lcd enable"); imx233_pinctrl_acquire(1, 24, "lcd hsync"); imx233_pinctrl_acquire(1, 25, "lcd vsync"); - imx233_pinctrl_acquire_mask(1, 0x3ffff, "lcd data"); + //imx233_pinctrl_acquire_mask(1, 0x3ffff, "lcd data"); if(use_lcdif) { imx233_pinctrl_set_function(1, 25, PINCTRL_FUNCTION_MAIN); /* lcd_vsync */ @@ -71,7 +71,7 @@ static void setup_lcd_pins(bool use_lcdif) else { HW_PINCTRL_MUXSELn_SET(2) = 0xffffffff; /* lcd_d{0-15} */ - imx233_pinctrl_enable_gpio_mask(1, 0x3ffffff, false); /* lcd_{d{0-17},reset,rs,wr,cs,dotclk,enable,hsync,vsync} */ + HW_PINCTRL_DOEn_CLR(1) = 0x3ffffff; /* lcd_{d{0-17},reset,rs,wr,cs,dotclk,enable,hsync,vsync} */ imx233_pinctrl_set_function(1, 16, PINCTRL_FUNCTION_GPIO); /* lcd_d16 */ imx233_pinctrl_set_function(1, 17, PINCTRL_FUNCTION_GPIO); /* lcd_d17 */ imx233_pinctrl_set_function(1, 19, PINCTRL_FUNCTION_GPIO); /* lcd_rs */ diff --git a/firmware/target/arm/imx233/creative-zenxfi3/button-zenxfi3.c b/firmware/target/arm/imx233/creative-zenxfi3/button-zenxfi3.c index c3f1908511..f89297b80c 100644 --- a/firmware/target/arm/imx233/creative-zenxfi3/button-zenxfi3.c +++ b/firmware/target/arm/imx233/creative-zenxfi3/button-zenxfi3.c @@ -144,7 +144,7 @@ void button_init_device(void) bool button_hold(void) { /* B0P04: #hold */ - return !imx233_pinctrl_get_gpio_mask(0, 0x10); + return !imx233_pinctrl_get_gpio(0, 4); } int button_read_device(void) @@ -172,10 +172,9 @@ int button_read_device(void) /* B2P07: #volume- * B2P08: #volume+ * PSWITCH: power */ - uint32_t mask = imx233_pinctrl_get_gpio_mask(2, 0x180); - if(!(mask & 0x80)) + if(!imx233_pinctrl_get_gpio(2, 7)) res |= BUTTON_VOL_DOWN; - if(!(mask & 0x100)) + if(!imx233_pinctrl_get_gpio(2, 8)) res |= BUTTON_VOL_UP; if(BF_RD(POWER_STS, PSWITCH) != 0 && power_ignore_counter == 0) res |= BUTTON_POWER; diff --git a/firmware/target/arm/imx233/creative-zenxfi3/lcd-zenxfi3.c b/firmware/target/arm/imx233/creative-zenxfi3/lcd-zenxfi3.c index de9e2df393..7afdaa316e 100644 --- a/firmware/target/arm/imx233/creative-zenxfi3/lcd-zenxfi3.c +++ b/firmware/target/arm/imx233/creative-zenxfi3/lcd-zenxfi3.c @@ -54,7 +54,7 @@ static void setup_lcd_pins(bool use_lcdif) imx233_pinctrl_acquire(1, 21, "lcd cs"); imx233_pinctrl_acquire(1, 23, "lcd enable"); imx233_pinctrl_acquire(1, 25, "lcd vsync"); - imx233_pinctrl_acquire_mask(1, 0x3ffff, "lcd data"); + //imx233_pinctrl_acquire_mask(1, 0x3ffff, "lcd data"); if(use_lcdif) { imx233_pinctrl_set_function(1, 25, PINCTRL_FUNCTION_MAIN); /* lcd_vsync */ @@ -70,7 +70,7 @@ static void setup_lcd_pins(bool use_lcdif) else { HW_PINCTRL_MUXSELn_SET(2) = 0xffffffff; /* lcd_d{0-15} */ - imx233_pinctrl_enable_gpio_mask(1, 0x2bfffff, false); /* lcd_{d{0-17},reset,rs,wr,cs,enable,vsync} */ + HW_PINCTRL_DOEn_CLR(1) = 0x2bfffff; imx233_pinctrl_set_function(1, 16, PINCTRL_FUNCTION_GPIO); /* lcd_d16 */ imx233_pinctrl_set_function(1, 17, PINCTRL_FUNCTION_GPIO); /* lcd_d17 */ imx233_pinctrl_set_function(1, 19, PINCTRL_FUNCTION_GPIO); /* lcd_rs */ diff --git a/firmware/target/arm/imx233/debug-imx233.c b/firmware/target/arm/imx233/debug-imx233.c index 7cb217f40f..7d690446d8 100644 --- a/firmware/target/arm/imx233/debug-imx233.c +++ b/firmware/target/arm/imx233/debug-imx233.c @@ -489,7 +489,7 @@ bool dbg_hw_info_pinctrl(void) lcd_clear_display(); for(int i = 0; i < 4; i++) - lcd_putsf(0, i, "DIN%d = 0x%08x", i, imx233_pinctrl_get_gpio_mask(i, 0xffffffff)); + lcd_putsf(0, i, "DIN%d = 0x%08x", i, HW_PINCTRL_DINn(i)); #ifdef IMX233_PINCTRL_DEBUG unsigned cur_line = 6; unsigned last_line = lcd_getheight() / font_get(lcd_getfont())->height; diff --git a/firmware/target/arm/imx233/pinctrl-imx233.c b/firmware/target/arm/imx233/pinctrl-imx233.c index ab59532543..96edf8db84 100644 --- a/firmware/target/arm/imx233/pinctrl-imx233.c +++ b/firmware/target/arm/imx233/pinctrl-imx233.c @@ -35,13 +35,6 @@ void imx233_pinctrl_acquire(unsigned bank, unsigned pin, const char *name) pin_use[bank][pin] = name; } -void imx233_pinctrl_acquire_mask(unsigned bank, uint32_t mask, const char *name) -{ - for(unsigned pin = 0; pin < 32; pin++) - if(mask & (1 << pin)) - imx233_pinctrl_acquire(bank, pin, name); -} - void imx233_pinctrl_release(unsigned bank, unsigned pin, const char *name) { if(pin_use[bank][pin] != NULL && pin_use[bank][pin] != name) @@ -49,13 +42,6 @@ void imx233_pinctrl_release(unsigned bank, unsigned pin, const char *name) pin_use[bank][pin] = NULL; } -void imx233_pinctrl_release_mask(unsigned bank, uint32_t mask, const char *name) -{ - for(unsigned pin = 0; pin < 32; pin++) - if(mask & (1 << pin)) - imx233_pinctrl_release(bank, pin, name); -} - const char *imx233_pinctrl_blame(unsigned bank, unsigned pin) { return pin_use[bank][pin]; diff --git a/firmware/target/arm/imx233/pinctrl-imx233.h b/firmware/target/arm/imx233/pinctrl-imx233.h index 05c2c15bea..3fcf042071 100644 --- a/firmware/target/arm/imx233/pinctrl-imx233.h +++ b/firmware/target/arm/imx233/pinctrl-imx233.h @@ -35,23 +35,24 @@ #define PINCTRL_FUNCTION_ALT2 2 #define PINCTRL_FUNCTION_GPIO 3 +#if IMX233_SUBTARGET >= 3700 #define PINCTRL_DRIVE_4mA 0 #define PINCTRL_DRIVE_8mA 1 #define PINCTRL_DRIVE_12mA 2 #define PINCTRL_DRIVE_16mA 3 /* not available on all pins */ +#else +#define PINCTRL_DRIVE_4mA 0 +#define PINCTRL_DRIVE_8mA 1 +#endif #ifdef IMX233_PINCTRL_DEBUG void imx233_pinctrl_acquire(unsigned bank, unsigned pin, const char *name); -void imx233_pinctrl_acquire_mask(unsigned bank, uint32_t mask, const char *name); void imx233_pinctrl_release(unsigned bank, unsigned pin, const char *name); -void imx233_pinctrl_release_mask(unsigned bank, uint32_t mask, const char *name); const char *imx233_pinctrl_blame(unsigned bank, unsigned pin); #else #define imx233_pinctrl_acquire(...) -#define imx233_pinctrl_acquire_mask(...) #define imx233_pinctrl_release(...) -#define imx233_pinctrl_release_mask(...) -#define imx233_pinctrl_blame(...) NULL +#define imx233_pinctrl_get_pin_use(...) NULL #endif typedef void (*pin_irq_cb_t)(int bank, int pin, intptr_t user); @@ -61,11 +62,19 @@ static inline void imx233_pinctrl_init(void) HW_PINCTRL_CTRL_CLR = BM_OR2(PINCTRL_CTRL, CLKGATE, SFTRST); } +#if IMX233_SUBTARGET >= 3700 static inline void imx233_pinctrl_set_drive(unsigned bank, unsigned pin, unsigned strength) { HW_PINCTRL_DRIVEn_CLR(4 * bank + pin / 8) = 3 << (4 * (pin % 8)); HW_PINCTRL_DRIVEn_SET(4 * bank + pin / 8) = strength << (4 * (pin % 8)); } +#else +static inline void imx233_pinctrl_set_drive(unsigned bank, unsigned pin, unsigned strength) +{ + HW_PINCTRL_DRIVEn_CLR(bank) = 1 << pin; + HW_PINCTRL_DRIVEn_SET(bank) = strength << pin; +} +#endif static inline void imx233_pinctrl_enable_gpio(unsigned bank, unsigned pin, bool enable) { @@ -75,14 +84,6 @@ static inline void imx233_pinctrl_enable_gpio(unsigned bank, unsigned pin, bool HW_PINCTRL_DOEn_CLR(bank) = 1 << pin; } -static inline void imx233_pinctrl_enable_gpio_mask(unsigned bank, uint32_t pin_mask, bool enable) -{ - if(enable) - HW_PINCTRL_DOEn_SET(bank) = pin_mask; - else - HW_PINCTRL_DOEn_CLR(bank) = pin_mask; -} - static inline void imx233_pinctrl_set_gpio(unsigned bank, unsigned pin, bool value) { if(value) @@ -91,25 +92,32 @@ static inline void imx233_pinctrl_set_gpio(unsigned bank, unsigned pin, bool val HW_PINCTRL_DOUTn_CLR(bank) = 1 << pin; } -static inline void imx233_pinctrl_set_gpio_mask(unsigned bank, uint32_t pin_mask, bool value) -{ - if(value) - HW_PINCTRL_DOUTn_SET(bank) = pin_mask; - else - HW_PINCTRL_DOUTn_CLR(bank) = pin_mask; -} - -static inline uint32_t imx233_pinctrl_get_gpio_mask(unsigned bank, uint32_t pin_mask) +static inline bool imx233_pinctrl_get_gpio(unsigned bank, unsigned pin) { - return HW_PINCTRL_DINn(bank) & pin_mask; + return (HW_PINCTRL_DINn(bank) >> pin) & 1; } static inline void imx233_pinctrl_set_function(unsigned bank, unsigned pin, unsigned function) { +#if IMX233_SUBTARGET >= 3700 HW_PINCTRL_MUXSELn_CLR(2 * bank + pin / 16) = 3 << (2 * (pin % 16)); HW_PINCTRL_MUXSELn_SET(2 * bank + pin / 16) = function << (2 * (pin % 16)); +#else + if(pin < 16) + { + HW_PINCTRL_MUXSELLn_CLR(bank) = 3 << (2 * pin); + HW_PINCTRL_MUXSELLn_SET(bank) = function << (2 * pin); + } + else + { + pin -= 16; + HW_PINCTRL_MUXSELHn_CLR(bank) = 3 << (2 * pin); + HW_PINCTRL_MUXSELHn_SET(bank) = function << (2 * pin); + } +#endif } +#if IMX233_SUBTARGET >= 3700 static inline void imx233_pinctrl_enable_pullup(unsigned bank, unsigned pin, bool enable) { if(enable) @@ -117,14 +125,14 @@ static inline void imx233_pinctrl_enable_pullup(unsigned bank, unsigned pin, boo else HW_PINCTRL_PULLn_CLR(bank) = 1 << pin; } - -static inline void imx233_pinctrl_enable_pullup_mask(unsigned bank, uint32_t pin_msk, bool enable) +#else +static inline void imx233_pinctrl_enable_pullup(unsigned bank, unsigned pin, bool enable) { - if(enable) - HW_PINCTRL_PULLn_SET(bank) = pin_msk; - else - HW_PINCTRL_PULLn_CLR(bank) = pin_msk; + (void) bank; + (void) pin; + (void) enable; } +#endif /** On irq, the pin irq interrupt is disable and then cb is called; * the setup_pin_irq function needs to be called again to enable it again */ @@ -158,6 +166,14 @@ static inline void imx233_pinctrl_setup_vpin(vpin_t vpin, const char *name, imx233_pinctrl_enable_pullup(bank, pin, pullup); } +#if IMX233_SUBTARGET < 3700 +#include "pins/pins-stmp3600.h" +#elif IMX233_SUBTARGET < 3770 +#include "pins/pins-stmp3700.h" +#elif IMX233_SUBTARGET < 3780 +#error implement this +#else #include "pins/pins-imx233.h" +#endif #endif /* __PINCTRL_IMX233_H__ */ diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c index 612ec39fb9..ad0dd16ff3 100644 --- a/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c +++ b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c @@ -79,7 +79,7 @@ bool button_debug_screen(void) lcd_putsf(0, 1, "RMI: id=%s p=%x s=%x", product_id, func_presence, sensor_prop); lcd_putsf(0, 2, "xmax=%d ymax=%d res=%d", x_max, y_max, sensor_resol); lcd_putsf(0, 3, "attn=%d ctl=%x int=%x", - imx233_pinctrl_get_gpio_mask(0, 0x08000000) ? 0 : 1, + imx233_pinctrl_get_gpio(0, 27) ? 0 : 1, rmi_read_single(RMI_DEVICE_CONTROL), rmi_read_single(RMI_INTERRUPT_REQUEST)); lcd_putsf(0, 4, "sensi: %d min_dist: %d", (int)sensitivity.value, min_dist); @@ -356,7 +356,7 @@ int touchpad_read_device(void) int button_read_device(void) { int res = 0; - if(!imx233_pinctrl_get_gpio_mask(1, 0x40000000)) + if(!imx233_pinctrl_get_gpio(1, 30)) res |= BUTTON_VOL_DOWN; /* The imx233 uses the voltage on the PSWITCH pin to detect power up/down * events as well as recovery mode. Since the power button is the power button diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c index ba62ebf59c..15e061103f 100644 --- a/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c +++ b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c @@ -58,12 +58,12 @@ static void i2c_sda_out(bool high) static bool i2c_scl_in(void) { - return imx233_pinctrl_get_gpio_mask(1, 1 << 22); + return imx233_pinctrl_get_gpio(1, 22); } static bool i2c_sda_in(void) { - return imx233_pinctrl_get_gpio_mask(1, 1 << 24); + return imx233_pinctrl_get_gpio(1, 24); } static void i2c_delay(int d) diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c index a99260f105..3fd63de623 100644 --- a/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c +++ b/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c @@ -73,7 +73,7 @@ static void setup_lcd_pins(bool use_lcdif) imx233_pinctrl_acquire(1, 21, "lcd cs"); imx233_pinctrl_acquire(1, 23, "lcd enable"); imx233_pinctrl_acquire(1, 25, "lcd vsync"); - imx233_pinctrl_acquire_mask(1, 0x3ffff, "lcd data"); + //imx233_pinctrl_acquire_mask(1, 0x3ffff, "lcd data"); if(use_lcdif) { imx233_pinctrl_set_function(1, 25, PINCTRL_FUNCTION_GPIO); /* lcd_vsync */ @@ -113,10 +113,10 @@ static void setup_lcd_pins_i80(bool i80) imx233_pinctrl_set_function(1, 21, PINCTRL_FUNCTION_GPIO); /* lcd_cs */ imx233_pinctrl_set_function(1, 23, PINCTRL_FUNCTION_GPIO); /* lcd_enable */ /* lcd_{rs,wr,cs,enable} */ - imx233_pinctrl_enable_gpio_mask(1, (1 << 19) | (1 << 20) | (1 << 21) | (1 << 23), true); - imx233_pinctrl_set_gpio_mask(1, (1 << 19) | (1 << 20) | (1 << 21) | (1 << 23), true); + HW_PINCTRL_DOEn_SET(1) = (1 << 19) | (1 << 20) | (1 << 21) | (1 << 23); + HW_PINCTRL_DOUTn_SET(1) = (1 << 19) | (1 << 20) | (1 << 21) | (1 << 23); - imx233_pinctrl_enable_gpio_mask(1, 0x3ffff, false); /* lcd_d{0-17} */ + HW_PINCTRL_DOEn_CLR(1) = 0x3ffff; /* lcd_d{0-17} */ HW_PINCTRL_MUXSELn_SET(2) = 0xffffffff; /* lcd_d{0-15} as GPIO */ imx233_pinctrl_set_function(1, 16, PINCTRL_FUNCTION_GPIO); /* lcd_d16 */ imx233_pinctrl_set_function(1, 17, PINCTRL_FUNCTION_GPIO); /* lcd_d17 */ @@ -125,7 +125,8 @@ static void setup_lcd_pins_i80(bool i80) } else { - imx233_pinctrl_set_gpio_mask(1, (1 << 19) | (1 << 20) | (1 << 21) | (1 << 23), true); + HW_PINCTRL_DOUTn_SET(1) = (1 << 19) | (1 << 20) | (1 << 21) | (1 << 23); + imx233_pinctrl_set_drive(1, 19, PINCTRL_DRIVE_4mA); /* lcd_rs */ imx233_pinctrl_set_drive(1, 20, PINCTRL_DRIVE_4mA); /* lcd_wr */ imx233_pinctrl_set_drive(1, 21, PINCTRL_DRIVE_4mA); /* lcd_cs */ @@ -133,7 +134,7 @@ static void setup_lcd_pins_i80(bool i80) imx233_pinctrl_set_function(1, 19, PINCTRL_FUNCTION_MAIN); /* lcd_rs */ imx233_pinctrl_set_function(1, 20, PINCTRL_FUNCTION_MAIN); /* lcd_wr */ imx233_pinctrl_set_function(1, 21, PINCTRL_FUNCTION_MAIN); /* lcd_cs */ - imx233_pinctrl_enable_gpio_mask(1, 0x3ffff, false); /* lcd_d{0-17} */ + HW_PINCTRL_DOEn_CLR(1) = 0x3ffff; /* lcd_d{0-17} */ HW_PINCTRL_MUXSELn_CLR(2) = 0xffffffff; /* lcd_d{0-15} as lcd_d{0-15} */ imx233_pinctrl_set_function(1, 16, PINCTRL_FUNCTION_MAIN); /* lcd_d16 */ imx233_pinctrl_set_function(1, 17, PINCTRL_FUNCTION_MAIN); /* lcd_d17 */ @@ -182,7 +183,7 @@ static uint32_t i80_read_register(uint32_t data_out) imx233_pinctrl_set_gpio(1, 19, true); /* lcd_rs */ imx233_pinctrl_set_gpio(1, 23, true); /* lcd_enable */ imx233_pinctrl_set_gpio(1, 20, true); /* lcd_wr */ - imx233_pinctrl_enable_gpio_mask(1, 0x3ffff, true); /* lcd_d{0-17} */ + HW_PINCTRL_DOEn_SET(1) = 0x3ffff; /* lcd_d{0-17} */ udelay(2); imx233_pinctrl_set_gpio(1, 19, false); /* lcd_rs */ udelay(1); @@ -190,11 +191,11 @@ static uint32_t i80_read_register(uint32_t data_out) udelay(1); imx233_pinctrl_set_gpio(1, 20, false); /* lcd_wr */ udelay(1); - imx233_pinctrl_set_gpio_mask(1, data_out & 0x3ffff, true); /* lcd_d{0-17} */ + HW_PINCTRL_DOUTn_SET(1) = data_out & 0x3ffff; /* lcd_d{0-17} */ udelay(1); imx233_pinctrl_set_gpio(1, 20, true); /* lcd_wr */ udelay(3); - imx233_pinctrl_enable_gpio_mask(1, 0x3ffff, false); /* lcd_d{0-17} */ + HW_PINCTRL_DOUTn_CLR(1) = 0x3ffff; /* lcd_d{0-17} */ udelay(2); imx233_pinctrl_set_gpio(1, 23, false); /* lcd_enable */ udelay(1); @@ -204,7 +205,7 @@ static uint32_t i80_read_register(uint32_t data_out) udelay(3); imx233_pinctrl_set_gpio(1, 23, false); /* lcd_enable */ udelay(2); - uint32_t data_in = imx233_pinctrl_get_gpio_mask(1, 0x3ffff); /* lcd_d{0-17} */ + uint32_t data_in = HW_PINCTRL_DINn(1) & 0x3ffff; /* lcd_d{0-17} */ udelay(1); imx233_pinctrl_set_gpio(1, 23, true); /* lcd_enable */ udelay(1); |