Skip to contentSkip to conversation

cs553x-gpio: add AMD CS5535/CS5536 GPIO driver support

PATCH In review Andres Salomon 3 participants 5 messages Feb 21, 2009 – Feb 25, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 cs553x-gpio: add AMD CS5535/CS5536 GPIO driver support

This creates a CS5535/CS5536 GPIO driver which uses a gpio_chip backend (allowing GPIO users to use the generic GPIO API if desired) while also allowing architecture-specific users directly (via the cs553x_gpio_* functions).

Tested on an OLPC machine. Some Leemotes also use CS5536 (with a mips cpu), which is why this is in drivers/gpio rather than arch/x86. Currently, it conflicts with older geode GPIO support; once MFGPT support is reworked to also be more generic, the older geode code will be removed.

---
 arch/x86/include/asm/geode.h |   28 +----
 drivers/gpio/Kconfig         |   10 ++
 drivers/gpio/Makefile        |    1 +
 drivers/gpio/cs553x-gpio.c   |  282 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/cs553x.h       |   58 +++++++++
 5 files changed, 352 insertions(+), 27 deletions(-)
 create mode 100644 drivers/gpio/cs553x-gpio.c
 create mode 100644 include/linux/cs553x.h
arch/x86/include/asm/geode.h +1 -27
index ad3c2ed..0798699 100644
@@ -12,6 +12,7 @@
 
 #include <asm/processor.h>
 #include <linux/io.h>
+#include <linux/cs553x.h>
 
 /* Generic southbridge functions */
 
@@ -115,33 +116,6 @@ extern int geode_get_dev_base(unsigned int dev);
 #define VSA_VR_MEM_SIZE		0x0200
 #define AMD_VSA_SIG		0x4132	/* signature is ascii 'VSA2' */
 #define GSW_VSA_SIG		0x534d  /* General Software signature */
-/* GPIO */
-
-#define GPIO_OUTPUT_VAL		0x00
-#define GPIO_OUTPUT_ENABLE	0x04
-#define GPIO_OUTPUT_OPEN_DRAIN	0x08
-#define GPIO_OUTPUT_INVERT	0x0C
-#define GPIO_OUTPUT_AUX1	0x10
-#define GPIO_OUTPUT_AUX2	0x14
-#define GPIO_PULL_UP		0x18
-#define GPIO_PULL_DOWN		0x1C
-#define GPIO_INPUT_ENABLE	0x20
-#define GPIO_INPUT_INVERT	0x24
-#define GPIO_INPUT_FILTER	0x28
-#define GPIO_INPUT_EVENT_COUNT	0x2C
-#define GPIO_READ_BACK		0x30
-#define GPIO_INPUT_AUX1		0x34
-#define GPIO_EVENTS_ENABLE	0x38
-#define GPIO_LOCK_ENABLE	0x3C
-#define GPIO_POSITIVE_EDGE_EN	0x40
-#define GPIO_NEGATIVE_EDGE_EN	0x44
-#define GPIO_POSITIVE_EDGE_STS	0x48
-#define GPIO_NEGATIVE_EDGE_STS	0x4C
-
-#define GPIO_MAP_X		0xE0
-#define GPIO_MAP_Y		0xE4
-#define GPIO_MAP_Z		0xE8
-#define GPIO_MAP_W		0xEC
 
 static inline u32 geode_gpio(unsigned int nr)
 {
drivers/gpio/Kconfig +10 -0
index 3d25654..797ff45 100644
@@ -145,6 +145,16 @@ config GPIO_TWL4030
 
 comment "PCI GPIO expanders:"
 
+config GPIO_CS553X
+	tristate "AMD cs5535/cs5536 GPIO support"
+	depends on PCI && !CS5535_GPIO && !MGEODE_LX
+	help
+	  The AMD cs5535 and cs5536 southbridges support 28 GPIO pins that
+	  can be used for quite a number of things.  The cs553x is found on
+	  AMD Geode and Lemote Yeeloong devices.
+
+	  If unsure, say N.
+
 config GPIO_BT8XX
 	tristate "BT8XX GPIO abuser"
 	depends on PCI && VIDEO_BT848=n
drivers/gpio/Makefile +1 -0
index 49ac64e..9690809 100644
@@ -11,4 +11,5 @@ obj-$(CONFIG_GPIO_PCA953X)	+= pca953x.o
 obj-$(CONFIG_GPIO_PCF857X)	+= pcf857x.o
 obj-$(CONFIG_GPIO_TWL4030)	+= twl4030-gpio.o
 obj-$(CONFIG_GPIO_XILINX)	+= xilinx_gpio.o
+obj-$(CONFIG_GPIO_CS553X)	+= cs553x-gpio.o
 obj-$(CONFIG_GPIO_BT8XX)	+= bt8xxgpio.o
drivers/gpio/cs553x-gpio.c new file +282 -0

282 lines not on this page · raw message

include/linux/cs553x.h new file +58 -0

58 lines not on this page · raw message

Signature · 1 line
1.5.6.5
#1 lore raw
Quoted 11 lines · On Fri, 20 Feb 2009 22:12:02 -0500 Andres Salomon <[email protected]> wrote:

This creates a CS5535/CS5536 GPIO driver which uses a gpio_chip backend (allowing GPIO users to use the generic GPIO API if desired) while also allowing architecture-specific users directly (via the cs553x_gpio_* functions).

Tested on an OLPC machine. Some Leemotes also use CS5536 (with a mips cpu), which is why this is in drivers/gpio rather than arch/x86. Currently, it conflicts with older geode GPIO support; once MFGPT support is reworked to also be more generic, the older geode code will be removed.

drivers/gpio/cs553x-gpio.c line 99

Quoted 3 lines
drivers/gpio/cs553x-gpio.c new file +3 -0
+EXPORT_SYMBOL_GPL(cs553x_gpio_set);
+EXPORT_SYMBOL_GPL(cs553x_gpio_clear);
+EXPORT_SYMBOL_GPL(cs553x_gpio_isset);

Nothing uses these exports. In fact these symbols could be made static to drivers/gpio/cs553x-gpio.c?

#2 lore raw
Quoted 15 lines · On Tue, 24 Feb 2009 12:06:37 -0800 Andrew Morton <[email protected]>…
Quoted 12 lines · On Fri, 20 Feb 2009 22:12:02 -0500 Andres Salomon <[email protected]> wrote:

This creates a CS5535/CS5536 GPIO driver which uses a gpio_chip backend (allowing GPIO users to use the generic GPIO API if desired) while also allowing architecture-specific users directly (via the cs553x_gpio_* functions).

Tested on an OLPC machine. Some Leemotes also use CS5536 (with a mips cpu), which is why this is in drivers/gpio rather than arch/x86. Currently, it conflicts with older geode GPIO support; once MFGPT support is reworked to also be more generic, the older geode code will be removed.

Quoted 6 lines

drivers/gpio/cs553x-gpio.c line 99

Quoted 3 lines
drivers/gpio/cs553x-gpio.c new file +3 -0
+EXPORT_SYMBOL_GPL(cs553x_gpio_set);
+EXPORT_SYMBOL_GPL(cs553x_gpio_clear);
+EXPORT_SYMBOL_GPL(cs553x_gpio_isset);

Nothing uses these exports. In fact these symbols could be made static to drivers/gpio/cs553x-gpio.c?

Not yet. The MFGPT, DCON, and olpc stuff will use them; I'm waiting to hear feedback on this patch before I write a generic MFGPT driver (or skip to cleaning up and submitting the DCON driver).

#3 lore raw
Quoted 4 lines · On Tue, 24 Feb 2009 15:19:37 -0500 Andres Salomon <[email protected]> wrote:

Not yet. The MFGPT, DCON, and olpc stuff will use them; I'm waiting to hear feedback on this patch before I write a generic MFGPT driver (or skip to cleaning up and submitting the DCON driver).

why can't they use the generic gpio api?

Signature · 6 lines
 Best regards,

 Alessandro Zummo,
  Tower Technologies - Torino, Italy

  http://www.towertech.it
#4 lore raw
Quoted 11 lines · On Wed, 25 Feb 2009 10:38:30 +0100 Alessandro Zummo…
Quoted 5 lines · On Tue, 24 Feb 2009 15:19:37 -0500 Andres Salomon <[email protected]> wrote:

Not yet. The MFGPT, DCON, and olpc stuff will use them; I'm waiting to hear feedback on this patch before I write a generic MFGPT driver (or skip to cleaning up and submitting the DCON driver).

why can't they use the generic gpio api?

Because the DCON (for example) has this bit of code:

         * According to HiMax, when powering the DCON up we should hold
         * SMB_DATA high for 8 SMB_CLK cycles.  This will force the DCON
         * state machine to reset to a (sane) initial state.  Mitch Bradley
         * did some testing and discovered that holding for 16 SMB_CLK cycles
         * worked a lot more reliably, so that's what we do here.
         *
         * According to the cs5536 spec, to set GPIO14 to SMB_CLK we must
         * simultaneously set AUX1 IN/OUT to GPIO14; ditto for SMB_DATA and
         * GPIO15.
         */
        geode_gpio_set(OLPC_GPIO_SMB_CLK|OLPC_GPIO_SMB_DATA, GPIO_OUTPUT_VAL);
        geode_gpio_set(OLPC_GPIO_SMB_CLK|OLPC_GPIO_SMB_DATA, GPIO_OUTPUT_ENABLE);
        geode_gpio_clear(OLPC_GPIO_SMB_CLK|OLPC_GPIO_SMB_DATA, GPIO_OUTPUT_AUX1);
        geode_gpio_clear(OLPC_GPIO_SMB_CLK|OLPC_GPIO_SMB_DATA, GPIO_OUTPUT_AUX2);
        geode_gpio_clear(OLPC_GPIO_SMB_CLK|OLPC_GPIO_SMB_DATA, GPIO_INPUT_AUX1);

        for (x = 0; x < 16; x++) {
                udelay(5);
                geode_gpio_clear(OLPC_GPIO_SMB_CLK, GPIO_OUTPUT_VAL);
                udelay(5);
                geode_gpio_set(OLPC_GPIO_SMB_CLK, GPIO_OUTPUT_VAL);
        }
        udelay(5);
        geode_gpio_set(OLPC_GPIO_SMB_CLK|OLPC_GPIO_SMB_DATA, GPIO_OUTPUT_AUX1);
        geode_gpio_set(OLPC_GPIO_SMB_CLK|OLPC_GPIO_SMB_DATA, GPIO_INPUT_AUX1);

The GPIO_OUTPUT_VALs can obviously use the generic GPIO API, but I have no idea how you'd map the INPUT_AUX1/OUTPUT_AUX1/OUTPUT_AUX2 stuff.

There are plenty other examples of this sort of thing.