x86: gpio: Correct GPIO setup ordering

The Intel GPIO driver can set up the GPIO pin mapping when the first GPIO
is probed. However, it assumes that the first GPIO to be probed is in the
first GPIO bank. If this is not the case then the init will write to the
wrong registers.

Fix this. Also add a note that this code is deprecated. We should move to
using device tree instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
Simon Glass 2016-03-06 19:28:13 -07:00 committed by Bin Meng
parent 963a811ab4
commit d6d50db8a3
2 changed files with 8 additions and 1 deletions

View file

@ -12,6 +12,7 @@
struct ich6_bank_platdata { struct ich6_bank_platdata {
uint16_t base_addr; uint16_t base_addr;
const char *bank_name; const char *bank_name;
int offset;
}; };
#define GPIO_MODE_NATIVE 0 #define GPIO_MODE_NATIVE 0
@ -146,6 +147,10 @@ struct pch_gpio_map {
} set3; } set3;
}; };
/*
* Deprecated functions to set up the GPIO map. The device tree should be used
* instead.
*/
int gpio_ich6_pinctrl_init(void); int gpio_ich6_pinctrl_init(void);
void setup_pch_gpios(u16 gpiobase, const struct pch_gpio_map *gpio); void setup_pch_gpios(u16 gpiobase, const struct pch_gpio_map *gpio);
void ich_gpio_set_gpio_map(const struct pch_gpio_map *map); void ich_gpio_set_gpio_map(const struct pch_gpio_map *map);

View file

@ -279,6 +279,7 @@ static int gpio_ich6_ofdata_to_platdata(struct udevice *dev)
debug("%s: Invalid register offset %d\n", __func__, offset); debug("%s: Invalid register offset %d\n", __func__, offset);
return -EINVAL; return -EINVAL;
} }
plat->offset = offset;
plat->base_addr = gpiobase + offset; plat->base_addr = gpiobase + offset;
plat->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset, plat->bank_name = fdt_getprop(gd->fdt_blob, dev->of_offset,
"bank-name", NULL); "bank-name", NULL);
@ -293,7 +294,8 @@ static int ich6_gpio_probe(struct udevice *dev)
struct ich6_bank_priv *bank = dev_get_priv(dev); struct ich6_bank_priv *bank = dev_get_priv(dev);
if (gd->arch.gpio_map) { if (gd->arch.gpio_map) {
setup_pch_gpios(plat->base_addr, gd->arch.gpio_map); setup_pch_gpios(plat->base_addr - plat->offset,
gd->arch.gpio_map);
gd->arch.gpio_map = NULL; gd->arch.gpio_map = NULL;
} }