Topcliff: Update PCH_GPIO driver to 2.6.35
PATCH 1/1 Topcliff: Update PCH_GPIO driver to 2.6.35
GPIO driver of Topcliff PCH
Topcliff PCH is the platform controller hub that is going to be used in Intel's upcoming general embedded platform. All IO peripherals in Topcliff PCH are actually devices sitting on AMBA bus. Topcliff PCH has GPIO I/F. Using this I/F, it is able to access system devices connected to GPIO.
--- drivers/gpio/Kconfig | 8 + drivers/gpio/Makefile | 1 + drivers/gpio/pch_gpio.c | 901 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/gpio/pch_gpio.h | 245 +++++++++++++ 4 files changed, 1155 insertions(+), 0 deletions(-) create mode 100644 drivers/gpio/pch_gpio.c create mode 100644 drivers/gpio/pch_gpio.h
drivers/gpio/Kconfig +8 -0
@@ -113,6 +113,14 @@ config GPIO_SCH comment "I2C GPIO expanders:" +config PCH_GPIO + tristate "PCH GPIO" + depends on PCI + help + This driver is for PCH GPIO of Topcliff which is an IOH for x86 + embedded processor. + This driver can access PCH GPIO device. + config GPIO_MAX7300 tristate "Maxim MAX7300 GPIO expander" depends on I2C
drivers/gpio/Makefile +1 -0
@@ -35,3 +35,4 @@ obj-$(CONFIG_GPIO_WM8994) += wm8994-gpio.o obj-$(CONFIG_GPIO_SCH) += sch_gpio.o obj-$(CONFIG_GPIO_RDC321X) += rdc321x-gpio.o obj-$(CONFIG_GPIO_JANZ_TTL) += janz-ttl.o +obj-$(CONFIG_PCH_GPIO) += pch_gpio.o
drivers/gpio/pch_gpio.c new file +901 -0
901 lines not on this page · raw message
drivers/gpio/pch_gpio.h new file +245 -0
245 lines not on this page · raw message
Signature · 1 line
1.6.0.6
Quoted 5 lines · Masayuki Ohtak
Topcliff PCH is the platform controller hub that is going to be used in Intel's upcoming general embedded platform. All IO peripherals in Topcliff PCH are actually devices sitting on AMBA bus. Topcliff PCH has GPIO I/F. Using this I/F, it is able to access system devices connected to GPIO.
This has a similar issue to the CAN driver - it isn't a standard kernel GPIO driver, it implements a custom ioctl based userspace ABI. This means it's not usable from within the kernel and isn't suitable for mainline. You should be implementing support for the device using the standard interfaces used by the other GPIO drivers in kernel.
Quoted 5 lines
+/**
+ *pch_gpio_handler- Implements the interrupt handler functionality of
+ * the gpio module.
+ * @irq: Contains the irq value
+ * @pData: Contains the reference to the base gpio address.
Please use the standard kernel coding style conventions for naming variables.
drivers/gpio/pch_gpio.c line 255
Quoted 5 lines
drivers/gpio/pch_gpio.c new file +5
-0+static irqreturn_t pch_gpio_handler (s32 irq,void *pData) +{ +irqreturn_t ret =IRQ_NONE ; +u32 pch_idisp_regval; +struct pch_gpio_chip *chip = (struct pch_gpio_chip *)pData;
No need to cast away from void.
drivers/gpio/pch_gpio.c line 261
Quoted 6 lines
drivers/gpio/pch_gpio.c new file +6
-0+ + pch_idisp_regval = + chip->pch_gpio_bit_mask &ioread32 (&chip->reg->idisp); +if (pch_idisp_regval !=0 ) { +/*invoke the callback */ + (*pch_gpio_cbr) (pch_idisp_regval, chip);
The interrupts from the controller should be hooked up to genirq, not using this custom callback mechanism.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 8 lines · On Monday, September 27, 2010 23:21:10 Masayuki Ohtake wrote:
Quoted 2 lines
You should be implementing support for the device using the standard interfaces used by the other GPIO drivers in kernel.
We are now modifying our GPIO driver with standard interface. I've got a bit of problem.
I don't understand how userspace accesses to the driver. Let me know how to ? sysfs only ?
sysfs only. look at GPIO_SYSFS in drivers/gpio/. support the common GPIO framework and the userspace API is taken care of for you. -mike
Hi Mike and Mark,
Thanks for your help.
But, I've got a bit of problem again.
I have modified for GPIO standard I/F referring other accepted GPIO driver.
According to Documentation/gpio.txt,
I tried to create GPIO node like below.
[root@localhost gpio]# ls
export gpiochip244 unexport
[root@localhost gpio]# echo 1 > export
bash: echo: write error: Invalid argument
[root@localhost gpio]#
But it fails.
Could you teach me the reason/cause why?
Thanks, Ohtake(OKISemi)
Quoted 1 line · Masayuki Ohtake
I have modified for GPIO standard I/F referring other accepted GPIO driver.
no idea what this driver is
Quoted 10 lines
According to
Documentation/gpio.txt,
I tried to create GPIO node like below.[root@localhost gpio]# ls
export gpiochip244 unexport
[root@localhost gpio]# echo 1 > export
bash: echo: write error: Invalid argument
[root@localhost gpio]#But it fails.
find out what range of GPIO numbers your driver is using and use those instead of "1"
-mike
Hi Mike,
Quoted 2 lines
find out what range of GPIO numbers your driver is using and use those instead of "1"
I have attached a part of our source file.
Since I set "ngpio=12",
I guess 0-11 can be used, thus, "echo 1 > export" should be success too. Is this true ?
Thanks, Ohtake(OKISemi)
----- Original Message -----
From: "Mike Frysinger" <[email protected]>
To: "Masayuki Ohtake" <[email protected]>
Cc: "Mark Brown" <[email protected]>; "Andrew Morton" <[email protected]>; "Samuel Ortiz" <[email protected]>; "Randy Dunlap" <[email protected]>; "Alek Du" <[email protected]>; <[email protected]>; <[email protected]>; "ML linux-kernel" <[email protected]>; "Qi" <[email protected]>; <[email protected]>; <[email protected]>; "Yong Y" <[email protected]>; "Tomoya MORINAGA" <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>
Sent: Tuesday, September 28, 2010 2:02 PM
Subject: Re: [MeeGo-Dev][PATCH] Topcliff: Update PCH_GPIO driver to 2.6.35
Quoted 1 line · Masayuki Ohtake
I have modified for GPIO standard I/F referring other accepted GPIO driver.
no idea what this driver is
Quoted 10 lines
According to
Documentation/gpio.txt,
I tried to create GPIO node like below.[root@localhost gpio]# ls
export gpiochip244 unexport
[root@localhost gpio]# echo 1 > export
bash: echo: write error: Invalid argument
[root@localhost gpio]#But it fails.
find out what range of GPIO numbers your driver is using and use those instead of "1"
-mike
begin 666 pch_gpio.c M<W1A=&EC('9O:60@<&-H7V=P:6]?<V5T=7 H<W1R=6-T('!C:%]G<&EO7V-H M:7 @*F-H:7 I#0I[#0H)<W1R=6-T(&=P:6]?8VAI<" J9W!I;R ]("9C:&EP M+3YG<&EO.PT*#0H)9W!I;RT^;&%B96P@/2!D979?;F%M92AC:&EP+3YD978I M.PT*"6=P:6\M/F]W;F5R(#T@5$A)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]D:7-A8FQE7V1E=FEC92AP9&5V*3L-"@T*97)R7W!C:5]E;F%B;&4Z D#0H):V9R964H8VAI<"D[#0H)<F5T=7)N(')E=#L-"GT-"@T*
`
end
Quoted 11 lines · Masayuki Ohtake
Quoted 2 lines
find out what range of GPIO numbers your driver is using and use those instead of "1"
I have attached a part of our source file.
Since I set "ngpio=12",
I guess 0-11 can be used, thus, "echo 1 > export" should be success too. Is this true ?begin 666
pch_gpio.cM<W1A=&EC('9O:60@<&-H7V=P:6]?<V5T=7 H<W1R=6-T('!C:%]G<&EO7V-H M:7 @*F-H:7 I#0I[#0H)<W1R=6-T(&=P:6]?8VAI<" J9W!I;R ]("9C:&EP
Your mail client has for some reason chosen to uuencode the attachment so it's going to be difficult for most people to read it. If you have debugfs enabled and mounted you can see the current GPIO banks in the file 'gpio' under debugfs.
Hi Mark,
Quoted 2 lines
Your mail client has for some reason chosen to uuencode the attachment so it's going to be difficult for most people to read it.
Sorry, I copied to mail body.
static void pch_gpio_setup(struct pch_gpio_chip *chip)
{
struct gpio_chip *gpio = &chip->gpio;
gpio->label = dev_name(chip->dev);
gpio->owner = THIS_MODULE;
gpio->direction_input = pch_gpio_direction_input;
gpio->get = pch_gpio_get;
gpio->direction_output = pch_gpio_direction_output;
gpio->set = pch_gpio_set;
gpio->dbg_show = NULL;
gpio->base = (u32)chip->pch_gpio_base_address;
gpio->ngpio = 12;
gpio->can_sleep = 0;
}static s32 __devinit pch_gpio_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
{
s32 ret;
struct pch_gpio_chip *chip;
chip = kzalloc(sizeof(struct pch_gpio_chip), GFP_KERNEL);
if (chip == NULL)
return -ENOMEM;
chip->dev = &pdev->dev;
ret = pci_enable_device(pdev);
if (ret) {
dev_err(&pdev->dev, "%s : pci_enable_device FAILED", __func__);
goto err_pci_enable;
}
ret = pci_request_regions(pdev, MODULE_NAME);
if (ret) {
dev_err(&pdev->dev, "%s : pci_request_regions FAILED",
__func__);
goto err_request_regions;
}
chip->pch_gpio_base_address = pci_iomap(pdev, 1, 0);
if (chip->pch_gpio_base_address == 0) {
dev_err(&pdev->dev, "%s : pci_iomap FAILED", __func__);
ret = -ENOMEM;
goto err_iomap;
}
chip->reg = chip->pch_gpio_base_address;
pci_set_drvdata(pdev, chip);
pch_gpio_cb_register(pch_gpio_cb, chip);
chip->pch_gpio_irq = pdev->irq;
device_set_wakeup_enable(&pdev->dev, 1);
pch_gpio_setup(chip);
ret = gpiochip_add(&chip->gpio);
if (ret) {
printk(KERN_ERR "PCH gpio: Failed to register GPIO\n");
goto err_gpiochip_add;
}
return 0;err_gpiochip_add:
pci_iounmap(pdev, chip->pch_gpio_base_address);
err_iomap:
pci_release_regions(pdev);
err_request_regions:
pci_disable_device(pdev);
err_pci_enable:
kfree(chip);
return ret;
}Thanks, Ohtake(OKISemi)
----- Original Message -----
From: "Mark Brown" <[email protected]>
To: "Masayuki Ohtake" <[email protected]>
Cc: "Mike Frysinger" <[email protected]>; "Andrew Morton" <[email protected]>; "Samuel Ortiz" <[email protected]>; "Randy Dunlap" <[email protected]>; "Alek Du" <[email protected]>; <[email protected]>; <[email protected]>; "ML linux-kernel" <[email protected]>; "Qi" <[email protected]>; <[email protected]>; <[email protected]>; "Yong Y" <[email protected]>; "Tomoya MORINAGA" <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>
Sent: Tuesday, September 28, 2010 2:29 PM
Subject: Re: [MeeGo-Dev][PATCH] Topcliff: Update PCH_GPIO driver to 2.6.35
Quoted 19 lines · Masayuki Ohtake
Quoted 5 lines
Quoted 3 lines
find out what range of GPIO numbers your driver is using and use those instead of "1"
I have attached a part of our source file.
Quoted 7 lines
Since I set "ngpio=12",
I guess 0-11 can be used, thus, "echo 1 > export" should be success too. Is this true ?begin 666
pch_gpio.cM<W1A=&EC('9O:60@<&-H7V=P:6]?<V5T=7 H<W1R=6-T('!C:%]G<&EO7V-H M:7 @*F-H:7 I#0I[#0H)<W1R=6-T(&=P:6]?8VAI<" J9W!I;R ]("9C:&EPYour mail client has for some reason chosen to uuencode the attachment so it's going to be difficult for most people to read it. If you have debugfs enabled and mounted you can see the current GPIO banks in the file 'gpio' under debugfs.
Quoted 1 line · Masayuki Ohtake
gpio->base = (u32)chip->pch_gpio_base_address;
This is the number that will be assigned to the first GPIO if the chip registers successfully.
Quoted 1 line
gpio->ngpio = 12;
This is the number of GPIOs your chip has.
Quoted 1 line
chip->pch_gpio_base_address = pci_iomap(pdev, 1, 0);
This initialisation is incorrect and is likely to fail. gpiolib knows nothing of how your chip is controlled, the base is the base for the GPIO numbers used to access GPIOs in gpiolib. Please refer to other gpiolib drivers for examples of how to use the gpilib APIs.
Quoted 8 lines · Masayuki Ohtake
Quoted 2 lines
find out what range of GPIO numbers your driver is using and use those instead of "1"
I have attached a part of our source file.
Since I set "ngpio=12",
I guess 0-11 can be used, thus, "echo 1 > export" should be success too. Is this true ?
there are often multiple gpio sources in a system. whichever one is registered first (usually the arch/cpu specific one) tends to start at 0.
i'm merely providing generic gpio information. i know nothing of your specific arch/cpu/board setup. you'll have to do some digging/debugging on your side.
-mike
Hi Mike and Mark,
Quoted 5 lines
[root@localhost gpio]# ls
export gpiochip244 unexport
[root@localhost gpio]# echo 1 > export
bash: echo: write error: Invalid argument
[root@localhost gpio]#
I could confirm GPIO node creation with success using the following command. echo 244 > export
It seems "gpiochip244" means base GPIO number is 244 NOT 0.
Thanks, Ohtake(OKISemi)
----- Original Message -----
From: "Mike Frysinger" <[email protected]>
To: "Masayuki Ohtake" <[email protected]>
Cc: "Mark Brown" <[email protected]>; "Andrew Morton" <[email protected]>; "Samuel Ortiz" <[email protected]>; "Randy Dunlap" <[email protected]>; "Alek Du" <[email protected]>; <[email protected]>; <[email protected]>; "ML linux-kernel" <[email protected]>; "Qi" <[email protected]>; <[email protected]>; <[email protected]>; "Yong Y" <[email protected]>; "Tomoya MORINAGA" <[email protected]>; <[email protected]>; <[email protected]>; <[email protected]>
Sent: Tuesday, September 28, 2010 2:32 PM
Subject: Re: [MeeGo-Dev][PATCH] Topcliff: Update PCH_GPIO driver to 2.6.35
Quoted 19 lines · Masayuki Ohtake
Quoted 8 lines
Quoted 2 lines
find out what range of GPIO numbers your driver is using and use those instead of "1"
I have attached a part of our source file.
Since I set "ngpio=12",
I guess 0-11 can be used, thus, "echo 1 > export" should be success too. Is this true ?there are often multiple gpio sources in a system. whichever one is registered first (usually the
arch/cpuspecific one) tends to start at 0.i'm merely providing generic gpio information. i know nothing of your specific
arch/cpu/boardsetup. you'll have to do some digging/debugging on your side.
-mike
Quoted 5 lines · Masayuki Ohtake
Quoted 2 lines
You should be implementing support for the device using the standard interfaces used by the other GPIO drivers in kernel.
I don't understand how userspace accesses to the driver. Let me know how to ? sysfs only ?
sysfs, though at least as often another driver in the kernel will interact with the GPIOs. Search the kernel for users of the gpiolib APIs.