x86: ich6-gpio: Make setup_pch_gpios() a weak function
PATCH 5/25 x86: ich6-gpio: Make setup_pch_gpios() a weak function
Define a weak verion of setup_pch_gpios() in the ich6-gpio driver and move the actual setup codes into the board support codes, so that the driver does not need to know any platform specific stuff (ie: include the platform specifc chipset header file).
--- arch/x86/include/asm/arch-coreboot/gpio.h | 3 ++ arch/x86/include/asm/arch-ivybridge/gpio.h | 3 ++ board/google/chromebook_link/link.c | 40 +++++++++++++++++++++++ drivers/gpio/intel_ich6_gpio.c | 52 +++--------------------------- 4 files changed, 50 insertions(+), 48 deletions(-)
arch/x86/include/asm/arch-coreboot/gpio.h +3 -0
@@ -7,4 +7,7 @@#ifndef _X86_ARCH_GPIO_H_#define _X86_ARCH_GPIO_H_ +/* Where in config space is the register that points to the GPIO registers? */ +#define PCI_CFG_GPIOBASE 0x48 +#endif /* _X86_ARCH_GPIO_H_ */
arch/x86/include/asm/arch-ivybridge/gpio.h +3 -0
@@ -7,4 +7,7 @@#ifndef _X86_ARCH_GPIO_H_#define _X86_ARCH_GPIO_H_ +/* Where in config space is the register that points to the GPIO registers? */ +#define PCI_CFG_GPIOBASE 0x48 +#endif /* _X86_ARCH_GPIO_H_ */
board/google/chromebook_link/link.c +40 -0
@@ -7,6 +7,9 @@#include <common.h> #include <cros_ec.h> #include <asm/gpio.h> +#include <asm/io.h> +#include <asm/pci.h> +#include <asm/arch/pch.h> int arch_early_init_r (void ) {
@@ -121,3 +124,40 @@ int board_early_init_f(void)return 0 ; } + +void setup_pch_gpios (u32 gpiobase,const struct pch_gpio_map *gpio) +{ +/* GPIO Set 1 */ +if (gpio->set1.level) +outl (*((u32 *)gpio->set1.level), gpiobase +GP_LVL ); +if (gpio->set1.mode) +outl (*((u32 *)gpio->set1.mode), gpiobase +GPIO_USE_SEL ); +if (gpio->set1.direction) +outl (*((u32 *)gpio->set1.direction), gpiobase +GP_IO_SEL ); +if (gpio->set1.reset) +outl (*((u32 *)gpio->set1.reset), gpiobase +GP_RST_SEL1 ); +if (gpio->set1.invert) +outl (*((u32 *)gpio->set1.invert), gpiobase +GPI_INV ); +if (gpio->set1.blink) +outl (*((u32 *)gpio->set1.blink), gpiobase +GPO_BLINK ); + +/* GPIO Set 2 */ +if (gpio->set2.level) +outl (*((u32 *)gpio->set2.level), gpiobase +GP_LVL2 ); +if (gpio->set2.mode) +outl (*((u32 *)gpio->set2.mode), gpiobase +GPIO_USE_SEL2 ); +if (gpio->set2.direction) +outl (*((u32 *)gpio->set2.direction), gpiobase +GP_IO_SEL2 ); +if (gpio->set2.reset) +outl (*((u32 *)gpio->set2.reset), gpiobase +GP_RST_SEL2 ); + +/* GPIO Set 3 */ +if (gpio->set3.level) +outl (*((u32 *)gpio->set3.level), gpiobase +GP_LVL3 ); +if (gpio->set3.mode) +outl (*((u32 *)gpio->set3.mode), gpiobase +GPIO_USE_SEL3 ); +if (gpio->set3.direction) +outl (*((u32 *)gpio->set3.direction), gpiobase +GP_IO_SEL3 ); +if (gpio->set3.reset) +outl (*((u32 *)gpio->set3.reset), gpiobase +GP_RST_SEL3 ); +}
drivers/gpio/intel_ich6_gpio.c +4 -48
83 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH 5/25 x86: ich6-gpio: Make setup_pch_gpios() a weak function
Hi Bin,
Quoted 6 lines · Bin Meng
Define a weak verion of
setup_pch_gpios()in the ich6-gpio driver and move the actual setup codes into the board support codes, so that the driver does not need to know any platform specific stuff (ie: include the platform specifc chipset header file).
Quoted 7 lines
Signed-off-by Bin Meng <[email protected]>--- arch/x86/include/asm/arch-coreboot/gpio.h | 3 ++ arch/x86/include/asm/arch-ivybridge/gpio.h | 3 ++ board/google/chromebook_link/link.c | 40 +++++++++++++++++++++++ drivers/gpio/intel_ich6_gpio.c | 52 +++--------------------------- 4 files changed, 50 insertions(+), 48 deletions(-)
Can we dispense with the weak? Let's just get a link error if it is missing. The problem is that weak functions give no signal when they are wrong.
If your platform doesn't have it, then you could create an empty function for now. But really we should (later) refactor this to run off the device tree somewhere.
Regards,
Simon
PATCH 5/25 x86: ich6-gpio: Make setup_pch_gpios() a weak function
Hi Simon,
Quoted 17 lines · Simon Glass
Hi Bin,
Quoted 6 lines · Bin Meng
Define a weak verion of
setup_pch_gpios()in the ich6-gpio driver and move the actual setup codes into the board support codes, so that the driver does not need to know any platform specific stuff (ie: include the platform specifc chipset header file).Quoted 7 lines
Signed-off-by Bin Meng <[email protected]>--- arch/x86/include/asm/arch-coreboot/gpio.h | 3 ++ arch/x86/include/asm/arch-ivybridge/gpio.h | 3 ++ board/google/chromebook_link/link.c | 40 +++++++++++++++++++++++ drivers/gpio/intel_ich6_gpio.c | 52 +++--------------------------- 4 files changed, 50 insertions(+), 48 deletions(-)
Quoted 8 lines
Can we dispense with the weak? Let's just get a link error if it is missing. The problem is that weak functions give no signal when they are wrong.
If your platform doesn't have it, then you could create an empty function for now. But really we should (later) refactor this to run off the device tree somewhere.
Sure, will do in v2.
Regards,
Bin