From: zyc Date: Wed, 4 Nov 2015 02:19:46 +0000 (+0800) Subject: camera: rk_camsys: rk3288: change gpio map method in camsys_gpio.h X-Git-Tag: firefly_0821_release~3646 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=67214f7efa4db5fb507603e3a9326760f8c207f8;p=firefly-linux-kernel-4.4.55.git camera: rk_camsys: rk3288: change gpio map method in camsys_gpio.h rk3288 gpio bank0 only has 24 pins not 32 pins,so modify the gpio map method for rk3288. Change-Id: I1d59b25d9acb0f51f9a1ad8ec74db2952534b1f2 Signed-off-by: ZhongYichong --- diff --git a/drivers/media/video/rk_camsys/camsys_gpio.h b/drivers/media/video/rk_camsys/camsys_gpio.h index f180b9773d0b..fb49b8155af6 100755 --- a/drivers/media/video/rk_camsys/camsys_gpio.h +++ b/drivers/media/video/rk_camsys/camsys_gpio.h @@ -1,92 +1,94 @@ #ifndef __RKCAMSYS_GPIO_H__ #define __RKCAMSYS_GPIO_H__ -//#include #if defined(CONFIG_ARCH_ROCKCHIP) #define RK30_PIN0_PA0 (0) -#define NUM_GROUP (32) -#define GPIO_BANKS (9) +#define NUM_GROUP (32) +#define GPIO_BANKS (9) #endif static inline unsigned int camsys_gpio_group_pin(unsigned char *io_name) { - unsigned char *pin_char; - unsigned char pin; + unsigned char *pin_char; + unsigned char pin; - if (strstr(io_name, "PA")) { - pin_char = strstr(io_name, "PA"); - pin_char += 2; - pin = *pin_char - 0x30; - } else if (strstr(io_name, "PB")) { - pin_char = strstr(io_name, "PB"); - pin_char += 2; - pin = *pin_char - 0x30; - pin += 8; - } else if (strstr(io_name, "PC")) { - pin_char = strstr(io_name, "PC"); - pin_char += 2; - pin = *pin_char - 0x30; - pin += 16; - } else if (strstr(io_name, "PD")) { - pin_char = strstr(io_name, "PD"); - pin_char += 2; - pin = *pin_char - 0x30; - pin += 24; - } - - return pin; + if (strstr(io_name, "PA")) { + pin_char = strstr(io_name, "PA"); + pin_char += 2; + pin = *pin_char - 0x30; + } else if (strstr(io_name, "PB")) { + pin_char = strstr(io_name, "PB"); + pin_char += 2; + pin = *pin_char - 0x30; + pin += 8; + } else if (strstr(io_name, "PC")) { + pin_char = strstr(io_name, "PC"); + pin_char += 2; + pin = *pin_char - 0x30; + pin += 16; + } else if (strstr(io_name, "PD")) { + pin_char = strstr(io_name, "PD"); + pin_char += 2; + pin = *pin_char - 0x30; + pin += 24; + } + return pin; } static inline unsigned int camsys_gpio_group(unsigned char *io_name) { - unsigned int group; - - if (strstr(io_name,"PIN0")) { - group = 0; - } else if (strstr(io_name,"PIN1")) { - group = 1; - } else if (strstr(io_name,"PIN2")) { - group = 2; - } else if (strstr(io_name,"PIN3")) { - group = 3; - } else if (strstr(io_name,"PIN4")) { - group = 4; - } else if (strstr(io_name,"PIN5")) { - group = 5; - } else if (strstr(io_name,"PIN6")) { - group = 6; - } else if (strstr(io_name,"PIN7")) { - group = 7; - } else if (strstr(io_name,"PIN8")) { - group = 8; - } + unsigned int group; - return group; + if (strstr(io_name, "PIN0")) + group = 0; + else if (strstr(io_name, "PIN1")) + group = 1; + else if (strstr(io_name, "PIN2")) + group = 2; + else if (strstr(io_name, "PIN3")) + group = 3; + else if (strstr(io_name, "PIN4")) + group = 4; + else if (strstr(io_name, "PIN5")) + group = 5; + else if (strstr(io_name, "PIN6")) + group = 6; + else if (strstr(io_name, "PIN7")) + group = 7; + else if (strstr(io_name, "PIN8")) + group = 8; + return group; } static inline unsigned int camsys_gpio_get(unsigned char *io_name) { - unsigned int gpio; - unsigned int group; - unsigned int group_pin; - -#if (defined(CONFIG_ARCH_RK3066B) || defined(CONFIG_ARCH_RK3188) || defined(CONFIG_ARCH_RK319X) ||defined(CONFIG_ARCH_ROCKCHIP)) - if (strstr(io_name, "RK30_")) { - gpio = RK30_PIN0_PA0; - group = camsys_gpio_group(io_name); - group_pin = camsys_gpio_group_pin(io_name); - - if (group >= GPIO_BANKS) { - gpio = 0xffffffff; - } else { - gpio += group*NUM_GROUP + group_pin; - } - } - + unsigned int gpio; + unsigned int group; + unsigned int group_pin; +#if (defined(CONFIG_ARCH_RK3066B) || defined(CONFIG_ARCH_RK3188) ||\ + defined(CONFIG_ARCH_RK319X) || defined(CONFIG_ARCH_ROCKCHIP)) + if (strstr(io_name, "RK30_")) { + gpio = RK30_PIN0_PA0; + group = camsys_gpio_group(io_name); + group_pin = camsys_gpio_group_pin(io_name); + if (group >= GPIO_BANKS) { + gpio = 0xffffffff; + } else { + if (cpu_is_rk3288()) { + /* bank 0 only has 24 pins ,not 32 pins */ + if (group > 0) { + gpio += 24 + (group - 1) * NUM_GROUP + + group_pin; + } else { + gpio += group_pin; + } + } else { + gpio += group * NUM_GROUP + group_pin; + } + } + } #endif - - - return gpio; + return gpio; } #endif