aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-adi2.h
diff options
context:
space:
mode:
authorSonic Zhang <sonic.zhang@analog.com>2013-09-03 04:28:59 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-09-19 08:37:27 -0400
commite9a03add0c6ed5341fc59ff9c76843c2888a33fa (patch)
tree3530e2d42d4bcd01c13cc3024cad2b4d8624ce6a /drivers/pinctrl/pinctrl-adi2.h
parent272b98c6455f00884f0350f775c5342358ebb73f (diff)
pinctrl: ADI PIN control driver for the GPIO controller on bf54x and bf60x.
The new ADI GPIO2 controller was introduced since the BF548 and BF60x processors. It differs a lot from the old one on BF5xx processors. So, create a pinctrl driver under the pinctrl framework. - Define gpio ports and pin interrupt controllers as individual platform devices. - Register a pinctrl driver for the whole GPIO ports and pin interrupt devices. - Probe pint devices before port devices. Put device instances into the global gpio and pint lists. - Define peripheral, irq and gpio reservation bit masks for each gpio port as runtime resources. - Save and restore gpio port and pint status MMRs in syscore PM functions. - Create the plug-in subdrivers to hold the pinctrl soc data for bf54x and bf60x. Add soc data into struct adi_pinctrl. Initialize the soc data in pin controller probe function. Get the pin groups and functions via the soc data reference. - Call gpiochip_add_pin_range() in gpio device probe function to register range cross reference between gpio device and pin control device. - Get range by pinctrl_find_gpio_range_from_pin(), find gpio_port object by container_of() and find adi_pinctrl by pin control device name. - Handle peripheral and gpio requests in pinctrl operation functions. - Demux gpio IRQs via the irq_domain created by each GPIO port. v2-changes: - Remove unlinke() directive. v3-changes: - Rename struct adi_pmx to adi_pinctrl. - Fix the comments of struct gpio_pint. - Remove unused pin_base in struct gpio_port. - Change pint_assign into bool type. - Add comments about the relationship between pint device and port device to the driver header. - Use BIT macro to shift bit. - Remove all bitmap reservation help functions. Inline reservation functions into the actual code. - Remove gpio and offset mutual reference help functions. - Remove all help functions to find gpio_port and adi_pinctrl structs. Get range by pinctrl_find_gpio_range_from_pin(), find gpio_port object by container_of() and find adi_pinctrl by pin control device name. - Pass bool type usage variable to port_setup help function. - Separate long bit operations into several lines and add comments. - Use debugfs to output all GPIO request information. - Avoid to set drvdata to NULL - Add explanation to function adi_gpio_init_int() - Call gpiochip_add_pin_range() in gpio device probe function to register range cross reference between gpio device and pin control device. - Remove the reference to pin control device from the gpio_port struct. Remove the reference list to gpio device from the adi_pinctrl struct. Replace the global adi_pinctrl list with adi_gpio_port_list. Walk through the gpio list to do power suspend and resume operations. - Remove the global GPIO base from struct adi_pinctrl, define pin base in the platform data for each GPIO port device. - Initialize adi_pinctrl_setup in arch_initcall(). - print the status of triggers, whether it is in GPIO mode, if it is flagged to be used as IRQ, etc in adi_pin_dbg_show(). - Create the plug-in subdrivers to hold the pinctrl soc data for bf54x and bf60x. Add soc data into struct adi_pinctrl. Initialize the soc data in pin controller probe function. Get the pin groups and functions via the soc data reference. v4-changes: - remove useless system_state checking. - replace dev_err with dev_warn in both irq and gpio pin cases. - comment on relationship between irq type and invert operation. - It is not necessary to check the reservation mode of the requested pin in IRQ chip operation. Remove the reservation map. - Use existing gpio/pinctrl subsystem debugfs files. Remove pinctrl-adi2 driver specific debugfs output. - Add linkport group and function information for bf60x. - Separate uart and ctsrts pins into 2 groups. - Separate APAPI and alternative ATAPI pins into 2 groups. Signed-off-by: Sonic Zhang <sonic.zhang@analog.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-adi2.h')
-rw-r--r--drivers/pinctrl/pinctrl-adi2.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/drivers/pinctrl/pinctrl-adi2.h b/drivers/pinctrl/pinctrl-adi2.h
new file mode 100644
index 000000000000..1f06f8df1fa3
--- /dev/null
+++ b/drivers/pinctrl/pinctrl-adi2.h
@@ -0,0 +1,75 @@
1/*
2 * Pinctrl Driver for ADI GPIO2 controller
3 *
4 * Copyright 2007-2013 Analog Devices Inc.
5 *
6 * Licensed under the GPLv2 or later
7 */
8
9#ifndef PINCTRL_PINCTRL_ADI2_H
10#define PINCTRL_PINCTRL_ADI2_H
11
12#include <linux/pinctrl/pinctrl.h>
13
14 /**
15 * struct adi_pin_group - describes a pin group
16 * @name: the name of this pin group
17 * @pins: an array of pins
18 * @num: the number of pins in this array
19 */
20struct adi_pin_group {
21 const char *name;
22 const unsigned *pins;
23 const unsigned num;
24};
25
26#define ADI_PIN_GROUP(n, p) \
27 { \
28 .name = n, \
29 .pins = p, \
30 .num = ARRAY_SIZE(p), \
31 }
32
33 /**
34 * struct adi_pmx_func - describes function mux setting of pin groups
35 * @name: the name of this function mux setting
36 * @groups: an array of pin groups
37 * @num_groups: the number of pin groups in this array
38 * @mux: the function mux setting array, end by zero
39 */
40struct adi_pmx_func {
41 const char *name;
42 const char * const *groups;
43 const unsigned num_groups;
44 const unsigned short *mux;
45};
46
47#define ADI_PMX_FUNCTION(n, g, m) \
48 { \
49 .name = n, \
50 .groups = g, \
51 .num_groups = ARRAY_SIZE(g), \
52 .mux = m, \
53 }
54
55/**
56 * struct adi_pinctrl_soc_data - ADI pin controller per-SoC configuration
57 * @functions: The functions supported on this SoC.
58 * @nfunction: The number of entries in @functions.
59 * @groups: An array describing all pin groups the pin SoC supports.
60 * @ngroups: The number of entries in @groups.
61 * @pins: An array describing all pins the pin controller affects.
62 * @npins: The number of entries in @pins.
63 */
64struct adi_pinctrl_soc_data {
65 const struct adi_pmx_func *functions;
66 int nfunctions;
67 const struct adi_pin_group *groups;
68 int ngroups;
69 const struct pinctrl_pin_desc *pins;
70 int npins;
71};
72
73void adi_pinctrl_soc_init(const struct adi_pinctrl_soc_data **soc);
74
75#endif /* PINCTRL_PINCTRL_ADI2_H */