diff options
author | Chris Kimber <chris.kimber@stericsson.com> | 2011-05-18 16:34:59 +0100 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@stericsson.com> | 2011-09-19 15:15:31 +0200 |
commit | 193962083213436f81e08e9e53288c0f44f4ac1c (patch) | |
tree | 67789678e511552683f64e51cf8724c800b6ac43 | |
parent | 1984f0558cca34c56b84c97884181a42a82d3701 (diff) |
ab8500-gpio: Allow initial configuration of GPIO registers
Allows the setting of the initial GPIO direction & pullup registers.
ST-Ericsson Linux next: Ported & patch created
ST-Ericsson ID: 334609
ST-Ericsson FOSS-OUT ID: Trivial
Change-Id: I676ed8129a96a2fe41865117e4c864edc09d01ce
Signed-off-by: Chris Kimber <chris.kimber@stericsson.com>
Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/23339
Reviewed-by: Andrew LYNN <andrew.lynn@stericsson.com>
-rw-r--r-- | arch/arm/mach-ux500/board-mop500.c | 19 | ||||
-rw-r--r-- | drivers/gpio/ab8500-gpio.c | 30 | ||||
-rw-r--r-- | include/linux/mfd/ab8500/gpio.h | 4 |
3 files changed, 41 insertions, 12 deletions
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c index 07921c9b5cd..2383cb3f6e8 100644 --- a/arch/arm/mach-ux500/board-mop500.c +++ b/arch/arm/mach-ux500/board-mop500.c @@ -95,7 +95,7 @@ static struct platform_device snowball_led_dev = { static struct ab8500_gpio_platform_data ab8500_gpio_pdata = { .gpio_base = MOP500_AB8500_GPIO(0), .irq_base = MOP500_AB8500_VIR_GPIO_IRQ_BASE, - /* config_reg is the initial configuration of ab8500 pins. + /* initial_pin_config is the initial configuration of ab8500 pins. * The pins can be configured as GPIO or alt functions based * on value present in GpioSel1 to GpioSel6 and AlternatFunction * register. This is the array of 7 configuration settings. @@ -105,9 +105,10 @@ static struct ab8500_gpio_platform_data ab8500_gpio_pdata = { * Pin GPIO2 (SysClkReq3) * Pin GPIO3 (SysClkReq4) * Pin GPIO4 (SysClkReq6) are configured as GPIO + * GpioSel2 = 0x9E => Pins GPIO10 to GPIO13 are configured as GPIO * GpioSel3 = 0x80 => Pin GPIO24 (SysClkReq7) is configured as GPIO * GpioSel4 = 0x01 => Pin GPIO25 (SysClkReq8) is configured as GPIO - * GpioSel5 = 0x7A => Pin GPIO36 (ApeSpiClk) + * GpioSel5 = 0x78 => Pin GPIO36 (ApeSpiClk) Pin GPIO37 (ApeSpiCSn) Pin GPIO38 (ApeSpiDout) Pin GPIO39 (ApeSpiDin) are configured as GPIO @@ -115,8 +116,18 @@ static struct ab8500_gpio_platform_data ab8500_gpio_pdata = { * AlternaFunction = 0x00 => If Pins GPIO10 to 13 are not configured * as GPIO then this register selectes the alternate functions */ - .config_reg = {0x0F, 0x9E, 0x80, 0x01, - 0x7A, 0x02, 0x00}, + .initial_pin_config = {0x0F, 0x9E, 0x80, 0x01, 0x78, 0x02, 0x00}, + + /* initial_pin_direction allows for the initial GPIO direction to + * be set. + */ + .initial_pin_direction = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + + /* + * initial_pin_pullups allows for the intial configuration of the + * GPIO pullup/pulldown configuration. + */ + .initial_pin_pullups = {0xE0, 0x01, 0x00, 0x00, 0x00, 0x00}, }; #ifdef CONFIG_INPUT_AB8500_ACCDET diff --git a/drivers/gpio/ab8500-gpio.c b/drivers/gpio/ab8500-gpio.c index 46040219713..bd095d7e7e7 100644 --- a/drivers/gpio/ab8500-gpio.c +++ b/drivers/gpio/ab8500-gpio.c @@ -413,7 +413,7 @@ static int __devinit ab8500_gpio_probe(struct platform_device *pdev) int i; pdata = ab8500_pdata->gpio; - if (!pdata) { + if (!pdata) { dev_err(&pdev->dev, "gpio platform data missing\n"); return -ENODEV; } @@ -430,24 +430,40 @@ static int __devinit ab8500_gpio_probe(struct platform_device *pdev) ab8500_gpio->chip.dev = &pdev->dev; ab8500_gpio->chip.base = pdata->gpio_base; ab8500_gpio->irq_base = pdata->irq_base; + /* initialize the lock */ mutex_init(&ab8500_gpio->lock); + /* * AB8500 core will handle and clear the IRQ - * configre GPIO based on config-reg value. - * These values are for selecting the PINs as - * GPIO or alternate function + * configure GPIO based on initial_pins_{config, direction, pullups} + * value. + * These values are for selecting the PINs as GPIO + * or alternative function */ - for (i = AB8500_GPIO_SEL1_REG; i <= AB8500_GPIO_SEL6_REG; i++) { + for (i = AB8500_GPIO_SEL1_REG; i <= AB8500_GPIO_SEL6_REG; i++) { ret = abx500_set_register_interruptible(ab8500_gpio->dev, AB8500_MISC, i, - pdata->config_reg[i]); + pdata->initial_pin_config[i]); + if (ret < 0) + goto out_free; + + ret = abx500_set_register_interruptible(ab8500_gpio->dev, + AB8500_MISC, i + AB8500_GPIO_DIR1_REG, + pdata->initial_pin_direction[i]); + if (ret < 0) + goto out_free; + + ret = abx500_set_register_interruptible(ab8500_gpio->dev, + AB8500_MISC, i + AB8500_GPIO_PUD1_REG, + pdata->initial_pin_pullups[i]); if (ret < 0) goto out_free; } + ret = abx500_set_register_interruptible(ab8500_gpio->dev, AB8500_MISC, AB8500_GPIO_ALTFUN_REG, - pdata->config_reg[ALTFUN_REG_INDEX]); + pdata->initial_pin_config[ALTFUN_REG_INDEX]); if (ret < 0) goto out_free; diff --git a/include/linux/mfd/ab8500/gpio.h b/include/linux/mfd/ab8500/gpio.h index 8ab95be71af..76d5ee22c60 100644 --- a/include/linux/mfd/ab8500/gpio.h +++ b/include/linux/mfd/ab8500/gpio.h @@ -15,7 +15,9 @@ struct ab8500_gpio_platform_data { int gpio_base; u32 irq_base; - u8 config_reg[7]; + u8 initial_pin_config[7]; + u8 initial_pin_direction[6]; + u8 initial_pin_pullups[6]; }; int ab8500_config_pull_up_or_down(struct device *dev, |