1 Index: linux-3.10.49/drivers/gpio/Kconfig
2 ===================================================================
3 --- linux-3.10.49.orig/drivers/gpio/Kconfig 2014-07-17 23:58:15.000000000 +0100
4 +++ linux-3.10.49/drivers/gpio/Kconfig 2014-07-27 05:55:40.312389198 +0100
6 Qualcomm MSM chips. Most of the pins on the MSM can be
7 selected for GPIO, and are controlled by this driver.
10 + tristate "Cavium OCTEON GPIO"
11 + depends on GPIOLIB && CPU_CAVIUM_OCTEON
14 + Say yes here to support the on-chip GPIO lines on the OCTEON
20 Index: linux-3.10.49/drivers/gpio/Makefile
21 ===================================================================
22 --- linux-3.10.49.orig/drivers/gpio/Makefile 2014-07-17 23:58:15.000000000 +0100
23 +++ linux-3.10.49/drivers/gpio/Makefile 2014-07-27 05:55:40.312389198 +0100
25 # Device drivers. Generally keep list sorted alphabetically
26 obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o
28 +obj-$(CONFIG_GPIO_OCTEON) += gpio-octeon.o
29 obj-$(CONFIG_GPIO_74X164) += gpio-74x164.o
30 obj-$(CONFIG_GPIO_ADNP) += gpio-adnp.o
31 obj-$(CONFIG_GPIO_ADP5520) += gpio-adp5520.o
32 Index: linux-3.10.49/drivers/gpio/gpio-octeon.c
33 ===================================================================
34 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
35 +++ linux-3.10.49/drivers/gpio/gpio-octeon.c 2014-07-27 05:55:40.312389198 +0100
38 + * This file is subject to the terms and conditions of the GNU General Public
39 + * License. See the file "COPYING" in the main directory of this archive
42 + * Copyright (C) 2011,2012 Cavium Inc.
45 +#include <linux/platform_device.h>
46 +#include <linux/kernel.h>
47 +#include <linux/module.h>
48 +#include <linux/gpio.h>
49 +#include <linux/io.h>
51 +#include <asm/octeon/octeon.h>
52 +#include <asm/octeon/cvmx-gpio-defs.h>
54 +#define DRV_VERSION "1.0"
55 +#define DRV_DESCRIPTION "Cavium Inc. OCTEON GPIO Driver"
59 +#define TX_CLEAR 0x90
61 + * The address offset of the GPIO configuration register for a given
64 +static unsigned int bit_cfg_reg(unsigned int gpio)
69 + return 8 * (gpio - 16) + 0x100;
73 + struct gpio_chip chip;
77 +static int octeon_gpio_dir_in(struct gpio_chip *chip, unsigned offset)
79 + struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip);
81 + cvmx_write_csr(gpio->register_base + bit_cfg_reg(offset), 0);
85 +static void octeon_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
87 + struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip);
88 + u64 mask = 1ull << offset;
89 + u64 reg = gpio->register_base + (value ? TX_SET : TX_CLEAR);
90 + cvmx_write_csr(reg, mask);
93 +static int octeon_gpio_dir_out(struct gpio_chip *chip, unsigned offset,
96 + struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip);
97 + union cvmx_gpio_bit_cfgx cfgx;
100 + octeon_gpio_set(chip, offset, value);
105 + cvmx_write_csr(gpio->register_base + bit_cfg_reg(offset), cfgx.u64);
109 +static int octeon_gpio_get(struct gpio_chip *chip, unsigned offset)
111 + struct octeon_gpio *gpio = container_of(chip, struct octeon_gpio, chip);
112 + u64 read_bits = cvmx_read_csr(gpio->register_base + RX_DAT);
114 + return ((1ull << offset) & read_bits) != 0;
117 +static int octeon_gpio_probe(struct platform_device *pdev)
119 + struct octeon_gpio *gpio;
120 + struct gpio_chip *chip;
121 + struct resource *res_mem;
124 + gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
127 + chip = &gpio->chip;
129 + res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
130 + if (res_mem == NULL) {
131 + dev_err(&pdev->dev, "found no memory resource\n");
135 + if (!devm_request_mem_region(&pdev->dev, res_mem->start,
136 + resource_size(res_mem),
138 + dev_err(&pdev->dev, "request_mem_region failed\n");
142 + gpio->register_base = (u64)devm_ioremap(&pdev->dev, res_mem->start,
143 + resource_size(res_mem));
146 + pdev->dev.platform_data = chip;
147 + chip->label = "octeon-gpio";
148 + chip->dev = &pdev->dev;
149 + chip->owner = THIS_MODULE;
151 + chip->can_sleep = 0;
153 + chip->direction_input = octeon_gpio_dir_in;
154 + chip->get = octeon_gpio_get;
155 + chip->direction_output = octeon_gpio_dir_out;
156 + chip->set = octeon_gpio_set;
157 + err = gpiochip_add(chip);
161 + dev_info(&pdev->dev, "version: " DRV_VERSION "\n");
166 +static int octeon_gpio_remove(struct platform_device *pdev)
168 + struct gpio_chip *chip = pdev->dev.platform_data;
169 + return gpiochip_remove(chip);
172 +static struct of_device_id octeon_gpio_match[] = {
174 + .compatible = "cavium,octeon-3860-gpio",
178 +MODULE_DEVICE_TABLE(of, octeon_gpio_match);
180 +static struct platform_driver octeon_gpio_driver = {
181 + .probe = octeon_gpio_probe,
182 + .remove = octeon_gpio_remove,
184 + .name = "octeon_gpio",
185 + .owner = THIS_MODULE,
186 + .of_match_table = octeon_gpio_match,
190 +module_platform_driver(octeon_gpio_driver);
192 +MODULE_DESCRIPTION(DRV_DESCRIPTION);
193 +MODULE_AUTHOR("David Daney");
194 +MODULE_LICENSE("GPL");
195 +MODULE_VERSION(DRV_VERSION);
196 Index: linux-3.10.49/arch/mips/Kconfig
197 ===================================================================
198 --- linux-3.10.49.orig/arch/mips/Kconfig 2014-07-27 05:55:38.620389229 +0100
199 +++ linux-3.10.49/arch/mips/Kconfig 2014-07-27 07:20:50.136294063 +0100
201 select USB_ARCH_HAS_OHCI
202 select USB_ARCH_HAS_EHCI
204 + select ARCH_REQUIRE_GPIOLIB
206 This option supports all of the Octeon reference boards from Cavium
207 Networks. It builds a kernel that dynamically determines the Octeon