1b5aa1006SYendapally Reddy Dhananjaya Reddy /* Copyright (C) 2016 Broadcom Corporation 2b5aa1006SYendapally Reddy Dhananjaya Reddy * 3b5aa1006SYendapally Reddy Dhananjaya Reddy * This program is free software; you can redistribute it and/or 4b5aa1006SYendapally Reddy Dhananjaya Reddy * modify it under the terms of the GNU General Public License as 5b5aa1006SYendapally Reddy Dhananjaya Reddy * published by the Free Software Foundation version 2. 6b5aa1006SYendapally Reddy Dhananjaya Reddy * 7b5aa1006SYendapally Reddy Dhananjaya Reddy * This program is distributed "as is" WITHOUT ANY WARRANTY of any 8b5aa1006SYendapally Reddy Dhananjaya Reddy * kind, whether express or implied; without even the implied warranty 9b5aa1006SYendapally Reddy Dhananjaya Reddy * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10b5aa1006SYendapally Reddy Dhananjaya Reddy * GNU General Public License for more details. 11b5aa1006SYendapally Reddy Dhananjaya Reddy * 12b5aa1006SYendapally Reddy Dhananjaya Reddy * This file contains the Northstar2 IOMUX driver that supports group 13b5aa1006SYendapally Reddy Dhananjaya Reddy * based PINMUX configuration. The PWM is functional only when the 14b5aa1006SYendapally Reddy Dhananjaya Reddy * corresponding mfio pin group is selected as gpio. 15b5aa1006SYendapally Reddy Dhananjaya Reddy */ 16b5aa1006SYendapally Reddy Dhananjaya Reddy 17b5aa1006SYendapally Reddy Dhananjaya Reddy #include <linux/err.h> 18b5aa1006SYendapally Reddy Dhananjaya Reddy #include <linux/io.h> 19b5aa1006SYendapally Reddy Dhananjaya Reddy #include <linux/of.h> 20b5aa1006SYendapally Reddy Dhananjaya Reddy #include <linux/pinctrl/pinconf.h> 21b5aa1006SYendapally Reddy Dhananjaya Reddy #include <linux/pinctrl/pinconf-generic.h> 22b5aa1006SYendapally Reddy Dhananjaya Reddy #include <linux/pinctrl/pinctrl.h> 23b5aa1006SYendapally Reddy Dhananjaya Reddy #include <linux/pinctrl/pinmux.h> 24b5aa1006SYendapally Reddy Dhananjaya Reddy #include <linux/platform_device.h> 25b5aa1006SYendapally Reddy Dhananjaya Reddy #include <linux/slab.h> 26b5aa1006SYendapally Reddy Dhananjaya Reddy 27b5aa1006SYendapally Reddy Dhananjaya Reddy #include "../core.h" 28b5aa1006SYendapally Reddy Dhananjaya Reddy #include "../pinctrl-utils.h" 29b5aa1006SYendapally Reddy Dhananjaya Reddy 30b5aa1006SYendapally Reddy Dhananjaya Reddy #define NS2_NUM_IOMUX 19 31b5aa1006SYendapally Reddy Dhananjaya Reddy #define NS2_NUM_PWM_MUX 4 32b5aa1006SYendapally Reddy Dhananjaya Reddy 33b5aa1006SYendapally Reddy Dhananjaya Reddy #define NS2_PIN_MUX_BASE0 0x00 34b5aa1006SYendapally Reddy Dhananjaya Reddy #define NS2_PIN_MUX_BASE1 0x01 35b5aa1006SYendapally Reddy Dhananjaya Reddy #define NS2_PIN_CONF_BASE 0x02 36b5aa1006SYendapally Reddy Dhananjaya Reddy #define NS2_MUX_PAD_FUNC1_OFFSET 0x04 37b5aa1006SYendapally Reddy Dhananjaya Reddy 38b5aa1006SYendapally Reddy Dhananjaya Reddy #define NS2_PIN_SRC_MASK 0x01 39b5aa1006SYendapally Reddy Dhananjaya Reddy #define NS2_PIN_PULL_MASK 0x03 40b5aa1006SYendapally Reddy Dhananjaya Reddy #define NS2_PIN_DRIVE_STRENGTH_MASK 0x07 41b5aa1006SYendapally Reddy Dhananjaya Reddy 42b5aa1006SYendapally Reddy Dhananjaya Reddy #define NS2_PIN_PULL_UP 0x01 43b5aa1006SYendapally Reddy Dhananjaya Reddy #define NS2_PIN_PULL_DOWN 0x02 44b5aa1006SYendapally Reddy Dhananjaya Reddy 45b5aa1006SYendapally Reddy Dhananjaya Reddy #define NS2_PIN_INPUT_EN_MASK 0x01 46b5aa1006SYendapally Reddy Dhananjaya Reddy 47b5aa1006SYendapally Reddy Dhananjaya Reddy /* 48b5aa1006SYendapally Reddy Dhananjaya Reddy * Northstar2 IOMUX register description 49b5aa1006SYendapally Reddy Dhananjaya Reddy * 50b5aa1006SYendapally Reddy Dhananjaya Reddy * @base: base address number 51b5aa1006SYendapally Reddy Dhananjaya Reddy * @offset: register offset for mux configuration of a group 52b5aa1006SYendapally Reddy Dhananjaya Reddy * @shift: bit shift for mux configuration of a group 53b5aa1006SYendapally Reddy Dhananjaya Reddy * @mask: mask bits 54b5aa1006SYendapally Reddy Dhananjaya Reddy * @alt: alternate function to set to 55b5aa1006SYendapally Reddy Dhananjaya Reddy */ 56b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_mux { 57b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int base; 58b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int offset; 59b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int shift; 60b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int mask; 61b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int alt; 62b5aa1006SYendapally Reddy Dhananjaya Reddy }; 63b5aa1006SYendapally Reddy Dhananjaya Reddy 64b5aa1006SYendapally Reddy Dhananjaya Reddy /* 65b5aa1006SYendapally Reddy Dhananjaya Reddy * Keep track of Northstar2 IOMUX configuration and prevent double 66b5aa1006SYendapally Reddy Dhananjaya Reddy * configuration 67b5aa1006SYendapally Reddy Dhananjaya Reddy * 68b5aa1006SYendapally Reddy Dhananjaya Reddy * @ns2_mux: Northstar2 IOMUX register description 69b5aa1006SYendapally Reddy Dhananjaya Reddy * @is_configured: flag to indicate whether a mux setting has already 70b5aa1006SYendapally Reddy Dhananjaya Reddy * been configured 71b5aa1006SYendapally Reddy Dhananjaya Reddy */ 72b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_mux_log { 73b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_mux mux; 74b5aa1006SYendapally Reddy Dhananjaya Reddy bool is_configured; 75b5aa1006SYendapally Reddy Dhananjaya Reddy }; 76b5aa1006SYendapally Reddy Dhananjaya Reddy 77b5aa1006SYendapally Reddy Dhananjaya Reddy /* 78b5aa1006SYendapally Reddy Dhananjaya Reddy * Group based IOMUX configuration 79b5aa1006SYendapally Reddy Dhananjaya Reddy * 80b5aa1006SYendapally Reddy Dhananjaya Reddy * @name: name of the group 81b5aa1006SYendapally Reddy Dhananjaya Reddy * @pins: array of pins used by this group 82b5aa1006SYendapally Reddy Dhananjaya Reddy * @num_pins: total number of pins used by this group 83b5aa1006SYendapally Reddy Dhananjaya Reddy * @mux: Northstar2 group based IOMUX configuration 84b5aa1006SYendapally Reddy Dhananjaya Reddy */ 85b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pin_group { 86b5aa1006SYendapally Reddy Dhananjaya Reddy const char *name; 87b5aa1006SYendapally Reddy Dhananjaya Reddy const unsigned int *pins; 88b5aa1006SYendapally Reddy Dhananjaya Reddy const unsigned int num_pins; 89b5aa1006SYendapally Reddy Dhananjaya Reddy const struct ns2_mux mux; 90b5aa1006SYendapally Reddy Dhananjaya Reddy }; 91b5aa1006SYendapally Reddy Dhananjaya Reddy 92b5aa1006SYendapally Reddy Dhananjaya Reddy /* 93b5aa1006SYendapally Reddy Dhananjaya Reddy * Northstar2 mux function and supported pin groups 94b5aa1006SYendapally Reddy Dhananjaya Reddy * 95b5aa1006SYendapally Reddy Dhananjaya Reddy * @name: name of the function 96b5aa1006SYendapally Reddy Dhananjaya Reddy * @groups: array of groups that can be supported by this function 97b5aa1006SYendapally Reddy Dhananjaya Reddy * @num_groups: total number of groups that can be supported by function 98b5aa1006SYendapally Reddy Dhananjaya Reddy */ 99b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pin_function { 100b5aa1006SYendapally Reddy Dhananjaya Reddy const char *name; 101b5aa1006SYendapally Reddy Dhananjaya Reddy const char * const *groups; 102b5aa1006SYendapally Reddy Dhananjaya Reddy const unsigned int num_groups; 103b5aa1006SYendapally Reddy Dhananjaya Reddy }; 104b5aa1006SYendapally Reddy Dhananjaya Reddy 105b5aa1006SYendapally Reddy Dhananjaya Reddy /* 106b5aa1006SYendapally Reddy Dhananjaya Reddy * Northstar2 IOMUX pinctrl core 107b5aa1006SYendapally Reddy Dhananjaya Reddy * 108b5aa1006SYendapally Reddy Dhananjaya Reddy * @pctl: pointer to pinctrl_dev 109b5aa1006SYendapally Reddy Dhananjaya Reddy * @dev: pointer to device 110b5aa1006SYendapally Reddy Dhananjaya Reddy * @base0: first IOMUX register base 111b5aa1006SYendapally Reddy Dhananjaya Reddy * @base1: second IOMUX register base 112b5aa1006SYendapally Reddy Dhananjaya Reddy * @pinconf_base: configuration register base 113b5aa1006SYendapally Reddy Dhananjaya Reddy * @groups: pointer to array of groups 114b5aa1006SYendapally Reddy Dhananjaya Reddy * @num_groups: total number of groups 115b5aa1006SYendapally Reddy Dhananjaya Reddy * @functions: pointer to array of functions 116b5aa1006SYendapally Reddy Dhananjaya Reddy * @num_functions: total number of functions 117b5aa1006SYendapally Reddy Dhananjaya Reddy * @mux_log: pointer to the array of mux logs 118b5aa1006SYendapally Reddy Dhananjaya Reddy * @lock: lock to protect register access 119b5aa1006SYendapally Reddy Dhananjaya Reddy */ 120b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl { 121b5aa1006SYendapally Reddy Dhananjaya Reddy struct pinctrl_dev *pctl; 122b5aa1006SYendapally Reddy Dhananjaya Reddy struct device *dev; 123b5aa1006SYendapally Reddy Dhananjaya Reddy void __iomem *base0; 124b5aa1006SYendapally Reddy Dhananjaya Reddy void __iomem *base1; 125b5aa1006SYendapally Reddy Dhananjaya Reddy void __iomem *pinconf_base; 126b5aa1006SYendapally Reddy Dhananjaya Reddy 127b5aa1006SYendapally Reddy Dhananjaya Reddy const struct ns2_pin_group *groups; 128b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int num_groups; 129b5aa1006SYendapally Reddy Dhananjaya Reddy 130b5aa1006SYendapally Reddy Dhananjaya Reddy const struct ns2_pin_function *functions; 131b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int num_functions; 132b5aa1006SYendapally Reddy Dhananjaya Reddy 133b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_mux_log *mux_log; 134b5aa1006SYendapally Reddy Dhananjaya Reddy 135b5aa1006SYendapally Reddy Dhananjaya Reddy spinlock_t lock; 136b5aa1006SYendapally Reddy Dhananjaya Reddy }; 137b5aa1006SYendapally Reddy Dhananjaya Reddy 138b5aa1006SYendapally Reddy Dhananjaya Reddy /* 139b5aa1006SYendapally Reddy Dhananjaya Reddy * Pin configuration info 140b5aa1006SYendapally Reddy Dhananjaya Reddy * 141b5aa1006SYendapally Reddy Dhananjaya Reddy * @base: base address number 142b5aa1006SYendapally Reddy Dhananjaya Reddy * @offset: register offset from base 143b5aa1006SYendapally Reddy Dhananjaya Reddy * @src_shift: slew rate control bit shift in the register 144b5aa1006SYendapally Reddy Dhananjaya Reddy * @input_en: input enable control bit shift 145b5aa1006SYendapally Reddy Dhananjaya Reddy * @pull_shift: pull-up/pull-down control bit shift in the register 146b5aa1006SYendapally Reddy Dhananjaya Reddy * @drive_shift: drive strength control bit shift in the register 147b5aa1006SYendapally Reddy Dhananjaya Reddy */ 148b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinconf { 149b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int base; 150b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int offset; 151b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int src_shift; 152b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int input_en; 153b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int pull_shift; 154b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int drive_shift; 155b5aa1006SYendapally Reddy Dhananjaya Reddy }; 156b5aa1006SYendapally Reddy Dhananjaya Reddy 157b5aa1006SYendapally Reddy Dhananjaya Reddy /* 158b5aa1006SYendapally Reddy Dhananjaya Reddy * Description of a pin in Northstar2 159b5aa1006SYendapally Reddy Dhananjaya Reddy * 160b5aa1006SYendapally Reddy Dhananjaya Reddy * @pin: pin number 161b5aa1006SYendapally Reddy Dhananjaya Reddy * @name: pin name 162b5aa1006SYendapally Reddy Dhananjaya Reddy * @pin_conf: pin configuration structure 163b5aa1006SYendapally Reddy Dhananjaya Reddy */ 164b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pin { 165b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int pin; 166b5aa1006SYendapally Reddy Dhananjaya Reddy char *name; 167b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinconf pin_conf; 168b5aa1006SYendapally Reddy Dhananjaya Reddy }; 169b5aa1006SYendapally Reddy Dhananjaya Reddy 170b5aa1006SYendapally Reddy Dhananjaya Reddy #define NS2_PIN_DESC(p, n, b, o, s, i, pu, d) \ 171b5aa1006SYendapally Reddy Dhananjaya Reddy { \ 172b5aa1006SYendapally Reddy Dhananjaya Reddy .pin = p, \ 173b5aa1006SYendapally Reddy Dhananjaya Reddy .name = n, \ 174b5aa1006SYendapally Reddy Dhananjaya Reddy .pin_conf = { \ 175b5aa1006SYendapally Reddy Dhananjaya Reddy .base = b, \ 176b5aa1006SYendapally Reddy Dhananjaya Reddy .offset = o, \ 177b5aa1006SYendapally Reddy Dhananjaya Reddy .src_shift = s, \ 178b5aa1006SYendapally Reddy Dhananjaya Reddy .input_en = i, \ 179b5aa1006SYendapally Reddy Dhananjaya Reddy .pull_shift = pu, \ 180b5aa1006SYendapally Reddy Dhananjaya Reddy .drive_shift = d, \ 181b5aa1006SYendapally Reddy Dhananjaya Reddy } \ 182b5aa1006SYendapally Reddy Dhananjaya Reddy } 183b5aa1006SYendapally Reddy Dhananjaya Reddy 184b5aa1006SYendapally Reddy Dhananjaya Reddy /* 185b5aa1006SYendapally Reddy Dhananjaya Reddy * List of pins in Northstar2 186b5aa1006SYendapally Reddy Dhananjaya Reddy */ 187b5aa1006SYendapally Reddy Dhananjaya Reddy static struct ns2_pin ns2_pins[] = { 188b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(0, "mfio_0", -1, 0, 0, 0, 0, 0), 189b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(1, "mfio_1", -1, 0, 0, 0, 0, 0), 190b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(2, "mfio_2", -1, 0, 0, 0, 0, 0), 191b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(3, "mfio_3", -1, 0, 0, 0, 0, 0), 192b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(4, "mfio_4", -1, 0, 0, 0, 0, 0), 193b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(5, "mfio_5", -1, 0, 0, 0, 0, 0), 194b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(6, "mfio_6", -1, 0, 0, 0, 0, 0), 195b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(7, "mfio_7", -1, 0, 0, 0, 0, 0), 196b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(8, "mfio_8", -1, 0, 0, 0, 0, 0), 197b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(9, "mfio_9", -1, 0, 0, 0, 0, 0), 198b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(10, "mfio_10", -1, 0, 0, 0, 0, 0), 199b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(11, "mfio_11", -1, 0, 0, 0, 0, 0), 200b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(12, "mfio_12", -1, 0, 0, 0, 0, 0), 201b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(13, "mfio_13", -1, 0, 0, 0, 0, 0), 202b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(14, "mfio_14", -1, 0, 0, 0, 0, 0), 203b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(15, "mfio_15", -1, 0, 0, 0, 0, 0), 204b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(16, "mfio_16", -1, 0, 0, 0, 0, 0), 205b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(17, "mfio_17", -1, 0, 0, 0, 0, 0), 206b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(18, "mfio_18", -1, 0, 0, 0, 0, 0), 207b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(19, "mfio_19", -1, 0, 0, 0, 0, 0), 208b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(20, "mfio_20", -1, 0, 0, 0, 0, 0), 209b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(21, "mfio_21", -1, 0, 0, 0, 0, 0), 210b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(22, "mfio_22", -1, 0, 0, 0, 0, 0), 211b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(23, "mfio_23", -1, 0, 0, 0, 0, 0), 212b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(24, "mfio_24", -1, 0, 0, 0, 0, 0), 213b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(25, "mfio_25", -1, 0, 0, 0, 0, 0), 214b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(26, "mfio_26", -1, 0, 0, 0, 0, 0), 215b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(27, "mfio_27", -1, 0, 0, 0, 0, 0), 216b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(28, "mfio_28", -1, 0, 0, 0, 0, 0), 217b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(29, "mfio_29", -1, 0, 0, 0, 0, 0), 218b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(30, "mfio_30", -1, 0, 0, 0, 0, 0), 219b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(31, "mfio_31", -1, 0, 0, 0, 0, 0), 220b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(32, "mfio_32", -1, 0, 0, 0, 0, 0), 221b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(33, "mfio_33", -1, 0, 0, 0, 0, 0), 222b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(34, "mfio_34", -1, 0, 0, 0, 0, 0), 223b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(35, "mfio_35", -1, 0, 0, 0, 0, 0), 224b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(36, "mfio_36", -1, 0, 0, 0, 0, 0), 225b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(37, "mfio_37", -1, 0, 0, 0, 0, 0), 226b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(38, "mfio_38", -1, 0, 0, 0, 0, 0), 227b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(39, "mfio_39", -1, 0, 0, 0, 0, 0), 228b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(40, "mfio_40", -1, 0, 0, 0, 0, 0), 229b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(41, "mfio_41", -1, 0, 0, 0, 0, 0), 230b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(42, "mfio_42", -1, 0, 0, 0, 0, 0), 231b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(43, "mfio_43", -1, 0, 0, 0, 0, 0), 232b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(44, "mfio_44", -1, 0, 0, 0, 0, 0), 233b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(45, "mfio_45", -1, 0, 0, 0, 0, 0), 234b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(46, "mfio_46", -1, 0, 0, 0, 0, 0), 235b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(47, "mfio_47", -1, 0, 0, 0, 0, 0), 236b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(48, "mfio_48", -1, 0, 0, 0, 0, 0), 237b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(49, "mfio_49", -1, 0, 0, 0, 0, 0), 238b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(50, "mfio_50", -1, 0, 0, 0, 0, 0), 239b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(51, "mfio_51", -1, 0, 0, 0, 0, 0), 240b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(52, "mfio_52", -1, 0, 0, 0, 0, 0), 241b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(53, "mfio_53", -1, 0, 0, 0, 0, 0), 242b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(54, "mfio_54", -1, 0, 0, 0, 0, 0), 243b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(55, "mfio_55", -1, 0, 0, 0, 0, 0), 244b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(56, "mfio_56", -1, 0, 0, 0, 0, 0), 245b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(57, "mfio_57", -1, 0, 0, 0, 0, 0), 246b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(58, "mfio_58", -1, 0, 0, 0, 0, 0), 247b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(59, "mfio_59", -1, 0, 0, 0, 0, 0), 248b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(60, "mfio_60", -1, 0, 0, 0, 0, 0), 249b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(61, "mfio_61", -1, 0, 0, 0, 0, 0), 250b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(62, "mfio_62", -1, 0, 0, 0, 0, 0), 251b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(63, "qspi_wp", 2, 0x0, 31, 30, 27, 24), 252b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(64, "qspi_hold", 2, 0x0, 23, 22, 19, 16), 253b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(65, "qspi_cs", 2, 0x0, 15, 14, 11, 8), 254b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(66, "qspi_sck", 2, 0x0, 7, 6, 3, 0), 255b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(67, "uart3_sin", 2, 0x04, 31, 30, 27, 24), 256b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(68, "uart3_sout", 2, 0x04, 23, 22, 19, 16), 257b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(69, "qspi_mosi", 2, 0x04, 15, 14, 11, 8), 258b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(70, "qspi_miso", 2, 0x04, 7, 6, 3, 0), 259b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(71, "spi0_fss", 2, 0x08, 31, 30, 27, 24), 260b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(72, "spi0_rxd", 2, 0x08, 23, 22, 19, 16), 261b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(73, "spi0_txd", 2, 0x08, 15, 14, 11, 8), 262b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(74, "spi0_sck", 2, 0x08, 7, 6, 3, 0), 263b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(75, "spi1_fss", 2, 0x0c, 31, 30, 27, 24), 264b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(76, "spi1_rxd", 2, 0x0c, 23, 22, 19, 16), 265b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(77, "spi1_txd", 2, 0x0c, 15, 14, 11, 8), 266b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(78, "spi1_sck", 2, 0x0c, 7, 6, 3, 0), 267b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(79, "sdio0_data7", 2, 0x10, 31, 30, 27, 24), 268b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(80, "sdio0_emmc_rst", 2, 0x10, 23, 22, 19, 16), 269b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(81, "sdio0_led_on", 2, 0x10, 15, 14, 11, 8), 270b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(82, "sdio0_wp", 2, 0x10, 7, 6, 3, 0), 271b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(83, "sdio0_data3", 2, 0x14, 31, 30, 27, 24), 272b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(84, "sdio0_data4", 2, 0x14, 23, 22, 19, 16), 273b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(85, "sdio0_data5", 2, 0x14, 15, 14, 11, 8), 274b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(86, "sdio0_data6", 2, 0x14, 7, 6, 3, 0), 275b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(87, "sdio0_cmd", 2, 0x18, 31, 30, 27, 24), 276b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(88, "sdio0_data0", 2, 0x18, 23, 22, 19, 16), 277b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(89, "sdio0_data1", 2, 0x18, 15, 14, 11, 8), 278b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(90, "sdio0_data2", 2, 0x18, 7, 6, 3, 0), 279b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(91, "sdio1_led_on", 2, 0x1c, 31, 30, 27, 24), 280b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(92, "sdio1_wp", 2, 0x1c, 23, 22, 19, 16), 281b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(93, "sdio0_cd_l", 2, 0x1c, 15, 14, 11, 8), 282b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(94, "sdio0_clk", 2, 0x1c, 7, 6, 3, 0), 283b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(95, "sdio1_data5", 2, 0x20, 31, 30, 27, 24), 284b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(96, "sdio1_data6", 2, 0x20, 23, 22, 19, 16), 285b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(97, "sdio1_data7", 2, 0x20, 15, 14, 11, 8), 286b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(98, "sdio1_emmc_rst", 2, 0x20, 7, 6, 3, 0), 287b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(99, "sdio1_data1", 2, 0x24, 31, 30, 27, 24), 288b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(100, "sdio1_data2", 2, 0x24, 23, 22, 19, 16), 289b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(101, "sdio1_data3", 2, 0x24, 15, 14, 11, 8), 290b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(102, "sdio1_data4", 2, 0x24, 7, 6, 3, 0), 291b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(103, "sdio1_cd_l", 2, 0x28, 31, 30, 27, 24), 292b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(104, "sdio1_clk", 2, 0x28, 23, 22, 19, 16), 293b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(105, "sdio1_cmd", 2, 0x28, 15, 14, 11, 8), 294b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(106, "sdio1_data0", 2, 0x28, 7, 6, 3, 0), 295b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(107, "ext_mdio_0", 2, 0x2c, 15, 14, 11, 8), 296b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(108, "ext_mdc_0", 2, 0x2c, 7, 6, 3, 0), 297b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(109, "usb3_p1_vbus_ppc", 2, 0x34, 31, 30, 27, 24), 298b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(110, "usb3_p1_overcurrent", 2, 0x34, 23, 22, 19, 16), 299b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(111, "usb3_p0_vbus_ppc", 2, 0x34, 15, 14, 11, 8), 300b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(112, "usb3_p0_overcurrent", 2, 0x34, 7, 6, 3, 0), 301b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(113, "usb2_presence_indication", 2, 0x38, 31, 30, 27, 24), 302b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(114, "usb2_vbus_present", 2, 0x38, 23, 22, 19, 16), 303b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(115, "usb2_vbus_ppc", 2, 0x38, 15, 14, 11, 8), 304b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(116, "usb2_overcurrent", 2, 0x38, 7, 6, 3, 0), 305b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(117, "sata_led1", 2, 0x3c, 15, 14, 11, 8), 306b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DESC(118, "sata_led0", 2, 0x3c, 7, 6, 3, 0), 307b5aa1006SYendapally Reddy Dhananjaya Reddy }; 308b5aa1006SYendapally Reddy Dhananjaya Reddy 309b5aa1006SYendapally Reddy Dhananjaya Reddy /* 310b5aa1006SYendapally Reddy Dhananjaya Reddy * List of groups of pins 311b5aa1006SYendapally Reddy Dhananjaya Reddy */ 312b5aa1006SYendapally Reddy Dhananjaya Reddy 313b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int nand_pins[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 314b5aa1006SYendapally Reddy Dhananjaya Reddy 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23}; 315b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int nor_data_pins[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 316b5aa1006SYendapally Reddy Dhananjaya Reddy 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}; 317b5aa1006SYendapally Reddy Dhananjaya Reddy 318b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int gpio_0_1_pins[] = {24, 25}; 319b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int pwm_0_pins[] = {24}; 320b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int pwm_1_pins[] = {25}; 321b5aa1006SYendapally Reddy Dhananjaya Reddy 322b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int uart1_ext_clk_pins[] = {26}; 323b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int nor_adv_pins[] = {26}; 324b5aa1006SYendapally Reddy Dhananjaya Reddy 325b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int gpio_2_5_pins[] = {27, 28, 29, 30}; 326b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int pcie_ab1_clk_wak_pins[] = {27, 28, 29, 30}; 327b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int nor_addr_0_3_pins[] = {27, 28, 29, 30}; 328b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int pwm_2_pins[] = {27}; 329b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int pwm_3_pins[] = {28}; 330b5aa1006SYendapally Reddy Dhananjaya Reddy 331b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int gpio_6_7_pins[] = {31, 32}; 332b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int pcie_a3_clk_wak_pins[] = {31, 32}; 333b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int nor_addr_4_5_pins[] = {31, 32}; 334b5aa1006SYendapally Reddy Dhananjaya Reddy 335b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int gpio_8_9_pins[] = {33, 34}; 336b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int pcie_b3_clk_wak_pins[] = {33, 34}; 337b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int nor_addr_6_7_pins[] = {33, 34}; 338b5aa1006SYendapally Reddy Dhananjaya Reddy 339b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int gpio_10_11_pins[] = {35, 36}; 340b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int pcie_b2_clk_wak_pins[] = {35, 36}; 341b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int nor_addr_8_9_pins[] = {35, 36}; 342b5aa1006SYendapally Reddy Dhananjaya Reddy 343b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int gpio_12_13_pins[] = {37, 38}; 344b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int pcie_a2_clk_wak_pins[] = {37, 38}; 345b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int nor_addr_10_11_pins[] = {37, 38}; 346b5aa1006SYendapally Reddy Dhananjaya Reddy 347b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int gpio_14_17_pins[] = {39, 40, 41, 42}; 348b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int uart0_modem_pins[] = {39, 40, 41, 42}; 349b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int nor_addr_12_15_pins[] = {39, 40, 41, 42}; 350b5aa1006SYendapally Reddy Dhananjaya Reddy 351b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int gpio_18_19_pins[] = {43, 44}; 352b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int uart0_rts_cts_pins[] = {43, 44}; 353b5aa1006SYendapally Reddy Dhananjaya Reddy 354b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int gpio_20_21_pins[] = {45, 46}; 355b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int uart0_in_out_pins[] = {45, 46}; 356b5aa1006SYendapally Reddy Dhananjaya Reddy 357b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int gpio_22_23_pins[] = {47, 48}; 358b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int uart1_dcd_dsr_pins[] = {47, 48}; 359b5aa1006SYendapally Reddy Dhananjaya Reddy 360b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int gpio_24_25_pins[] = {49, 50}; 361b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int uart1_ri_dtr_pins[] = {49, 50}; 362b5aa1006SYendapally Reddy Dhananjaya Reddy 363b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int gpio_26_27_pins[] = {51, 52}; 364b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int uart1_rts_cts_pins[] = {51, 52}; 365b5aa1006SYendapally Reddy Dhananjaya Reddy 366b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int gpio_28_29_pins[] = {53, 54}; 367b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int uart1_in_out_pins[] = {53, 54}; 368b5aa1006SYendapally Reddy Dhananjaya Reddy 369b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int gpio_30_31_pins[] = {55, 56}; 370b5aa1006SYendapally Reddy Dhananjaya Reddy static const unsigned int uart2_rts_cts_pins[] = {55, 56}; 371b5aa1006SYendapally Reddy Dhananjaya Reddy 372b5aa1006SYendapally Reddy Dhananjaya Reddy #define NS2_PIN_GROUP(group_name, ba, off, sh, ma, al) \ 373b5aa1006SYendapally Reddy Dhananjaya Reddy { \ 374b5aa1006SYendapally Reddy Dhananjaya Reddy .name = __stringify(group_name) "_grp", \ 375b5aa1006SYendapally Reddy Dhananjaya Reddy .pins = group_name ## _pins, \ 376b5aa1006SYendapally Reddy Dhananjaya Reddy .num_pins = ARRAY_SIZE(group_name ## _pins), \ 377b5aa1006SYendapally Reddy Dhananjaya Reddy .mux = { \ 378b5aa1006SYendapally Reddy Dhananjaya Reddy .base = ba, \ 379b5aa1006SYendapally Reddy Dhananjaya Reddy .offset = off, \ 380b5aa1006SYendapally Reddy Dhananjaya Reddy .shift = sh, \ 381b5aa1006SYendapally Reddy Dhananjaya Reddy .mask = ma, \ 382b5aa1006SYendapally Reddy Dhananjaya Reddy .alt = al, \ 383b5aa1006SYendapally Reddy Dhananjaya Reddy } \ 384b5aa1006SYendapally Reddy Dhananjaya Reddy } 385b5aa1006SYendapally Reddy Dhananjaya Reddy 386b5aa1006SYendapally Reddy Dhananjaya Reddy /* 387b5aa1006SYendapally Reddy Dhananjaya Reddy * List of Northstar2 pin groups 388b5aa1006SYendapally Reddy Dhananjaya Reddy */ 389b5aa1006SYendapally Reddy Dhananjaya Reddy static const struct ns2_pin_group ns2_pin_groups[] = { 390b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(nand, 0, 0, 31, 1, 0), 391b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(nor_data, 0, 0, 31, 1, 1), 392b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(gpio_0_1, 0, 0, 31, 1, 0), 393b5aa1006SYendapally Reddy Dhananjaya Reddy 394b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(uart1_ext_clk, 0, 4, 30, 3, 1), 395b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(nor_adv, 0, 4, 30, 3, 2), 396b5aa1006SYendapally Reddy Dhananjaya Reddy 397b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(gpio_2_5, 0, 4, 28, 3, 0), 398b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(pcie_ab1_clk_wak, 0, 4, 28, 3, 1), 399b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(nor_addr_0_3, 0, 4, 28, 3, 2), 400b5aa1006SYendapally Reddy Dhananjaya Reddy 401b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(gpio_6_7, 0, 4, 26, 3, 0), 402b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(pcie_a3_clk_wak, 0, 4, 26, 3, 1), 403b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(nor_addr_4_5, 0, 4, 26, 3, 2), 404b5aa1006SYendapally Reddy Dhananjaya Reddy 405b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(gpio_8_9, 0, 4, 24, 3, 0), 406b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(pcie_b3_clk_wak, 0, 4, 24, 3, 1), 407b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(nor_addr_6_7, 0, 4, 24, 3, 2), 408b5aa1006SYendapally Reddy Dhananjaya Reddy 409b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(gpio_10_11, 0, 4, 22, 3, 0), 410b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(pcie_b2_clk_wak, 0, 4, 22, 3, 1), 411b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(nor_addr_8_9, 0, 4, 22, 3, 2), 412b5aa1006SYendapally Reddy Dhananjaya Reddy 413b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(gpio_12_13, 0, 4, 20, 3, 0), 414b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(pcie_a2_clk_wak, 0, 4, 20, 3, 1), 415b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(nor_addr_10_11, 0, 4, 20, 3, 2), 416b5aa1006SYendapally Reddy Dhananjaya Reddy 417b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(gpio_14_17, 0, 4, 18, 3, 0), 418b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(uart0_modem, 0, 4, 18, 3, 1), 419b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(nor_addr_12_15, 0, 4, 18, 3, 2), 420b5aa1006SYendapally Reddy Dhananjaya Reddy 421b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(gpio_18_19, 0, 4, 16, 3, 0), 422b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(uart0_rts_cts, 0, 4, 16, 3, 1), 423b5aa1006SYendapally Reddy Dhananjaya Reddy 424b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(gpio_20_21, 0, 4, 14, 3, 0), 425b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(uart0_in_out, 0, 4, 14, 3, 1), 426b5aa1006SYendapally Reddy Dhananjaya Reddy 427b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(gpio_22_23, 0, 4, 12, 3, 0), 428b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(uart1_dcd_dsr, 0, 4, 12, 3, 1), 429b5aa1006SYendapally Reddy Dhananjaya Reddy 430b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(gpio_24_25, 0, 4, 10, 3, 0), 431b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(uart1_ri_dtr, 0, 4, 10, 3, 1), 432b5aa1006SYendapally Reddy Dhananjaya Reddy 433b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(gpio_26_27, 0, 4, 8, 3, 0), 434b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(uart1_rts_cts, 0, 4, 8, 3, 1), 435b5aa1006SYendapally Reddy Dhananjaya Reddy 436b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(gpio_28_29, 0, 4, 6, 3, 0), 437b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(uart1_in_out, 0, 4, 6, 3, 1), 438b5aa1006SYendapally Reddy Dhananjaya Reddy 439b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(gpio_30_31, 0, 4, 4, 3, 0), 440b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(uart2_rts_cts, 0, 4, 4, 3, 1), 441b5aa1006SYendapally Reddy Dhananjaya Reddy 442b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(pwm_0, 1, 0, 0, 1, 1), 443b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(pwm_1, 1, 0, 1, 1, 1), 444b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(pwm_2, 1, 0, 2, 1, 1), 445b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_GROUP(pwm_3, 1, 0, 3, 1, 1), 446b5aa1006SYendapally Reddy Dhananjaya Reddy }; 447b5aa1006SYendapally Reddy Dhananjaya Reddy 448b5aa1006SYendapally Reddy Dhananjaya Reddy /* 449b5aa1006SYendapally Reddy Dhananjaya Reddy * List of groups supported by functions 450b5aa1006SYendapally Reddy Dhananjaya Reddy */ 451b5aa1006SYendapally Reddy Dhananjaya Reddy 452b5aa1006SYendapally Reddy Dhananjaya Reddy static const char * const nand_grps[] = {"nand_grp"}; 453b5aa1006SYendapally Reddy Dhananjaya Reddy 454b5aa1006SYendapally Reddy Dhananjaya Reddy static const char * const nor_grps[] = {"nor_data_grp", "nor_adv_grp", 455b5aa1006SYendapally Reddy Dhananjaya Reddy "nor_addr_0_3_grp", "nor_addr_4_5_grp", "nor_addr_6_7_grp", 456b5aa1006SYendapally Reddy Dhananjaya Reddy "nor_addr_8_9_grp", "nor_addr_10_11_grp", "nor_addr_12_15_grp"}; 457b5aa1006SYendapally Reddy Dhananjaya Reddy 458b5aa1006SYendapally Reddy Dhananjaya Reddy static const char * const gpio_grps[] = {"gpio_0_1_grp", "gpio_2_5_grp", 459b5aa1006SYendapally Reddy Dhananjaya Reddy "gpio_6_7_grp", "gpio_8_9_grp", "gpio_10_11_grp", "gpio_12_13_grp", 460b5aa1006SYendapally Reddy Dhananjaya Reddy "gpio_14_17_grp", "gpio_18_19_grp", "gpio_20_21_grp", "gpio_22_23_grp", 461b5aa1006SYendapally Reddy Dhananjaya Reddy "gpio_24_25_grp", "gpio_26_27_grp", "gpio_28_29_grp", 462b5aa1006SYendapally Reddy Dhananjaya Reddy "gpio_30_31_grp"}; 463b5aa1006SYendapally Reddy Dhananjaya Reddy 464b5aa1006SYendapally Reddy Dhananjaya Reddy static const char * const pcie_grps[] = {"pcie_ab1_clk_wak_grp", 465b5aa1006SYendapally Reddy Dhananjaya Reddy "pcie_a3_clk_wak_grp", "pcie_b3_clk_wak_grp", "pcie_b2_clk_wak_grp", 466b5aa1006SYendapally Reddy Dhananjaya Reddy "pcie_a2_clk_wak_grp"}; 467b5aa1006SYendapally Reddy Dhananjaya Reddy 468b5aa1006SYendapally Reddy Dhananjaya Reddy static const char * const uart0_grps[] = {"uart0_modem_grp", 469b5aa1006SYendapally Reddy Dhananjaya Reddy "uart0_rts_cts_grp", "uart0_in_out_grp"}; 470b5aa1006SYendapally Reddy Dhananjaya Reddy 471b5aa1006SYendapally Reddy Dhananjaya Reddy static const char * const uart1_grps[] = {"uart1_ext_clk_grp", 472b5aa1006SYendapally Reddy Dhananjaya Reddy "uart1_dcd_dsr_grp", "uart1_ri_dtr_grp", "uart1_rts_cts_grp", 473b5aa1006SYendapally Reddy Dhananjaya Reddy "uart1_in_out_grp"}; 474b5aa1006SYendapally Reddy Dhananjaya Reddy 475b5aa1006SYendapally Reddy Dhananjaya Reddy static const char * const uart2_grps[] = {"uart2_rts_cts_grp"}; 476b5aa1006SYendapally Reddy Dhananjaya Reddy 477b5aa1006SYendapally Reddy Dhananjaya Reddy static const char * const pwm_grps[] = {"pwm_0_grp", "pwm_1_grp", 478b5aa1006SYendapally Reddy Dhananjaya Reddy "pwm_2_grp", "pwm_3_grp"}; 479b5aa1006SYendapally Reddy Dhananjaya Reddy 480b5aa1006SYendapally Reddy Dhananjaya Reddy #define NS2_PIN_FUNCTION(func) \ 481b5aa1006SYendapally Reddy Dhananjaya Reddy { \ 482b5aa1006SYendapally Reddy Dhananjaya Reddy .name = #func, \ 483b5aa1006SYendapally Reddy Dhananjaya Reddy .groups = func ## _grps, \ 484b5aa1006SYendapally Reddy Dhananjaya Reddy .num_groups = ARRAY_SIZE(func ## _grps), \ 485b5aa1006SYendapally Reddy Dhananjaya Reddy } 486b5aa1006SYendapally Reddy Dhananjaya Reddy 487b5aa1006SYendapally Reddy Dhananjaya Reddy /* 488b5aa1006SYendapally Reddy Dhananjaya Reddy * List of supported functions 489b5aa1006SYendapally Reddy Dhananjaya Reddy */ 490b5aa1006SYendapally Reddy Dhananjaya Reddy static const struct ns2_pin_function ns2_pin_functions[] = { 491b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_FUNCTION(nand), 492b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_FUNCTION(nor), 493b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_FUNCTION(gpio), 494b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_FUNCTION(pcie), 495b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_FUNCTION(uart0), 496b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_FUNCTION(uart1), 497b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_FUNCTION(uart2), 498b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_FUNCTION(pwm), 499b5aa1006SYendapally Reddy Dhananjaya Reddy }; 500b5aa1006SYendapally Reddy Dhananjaya Reddy 501b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_get_groups_count(struct pinctrl_dev *pctrl_dev) 502b5aa1006SYendapally Reddy Dhananjaya Reddy { 503b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 504b5aa1006SYendapally Reddy Dhananjaya Reddy 505b5aa1006SYendapally Reddy Dhananjaya Reddy return pinctrl->num_groups; 506b5aa1006SYendapally Reddy Dhananjaya Reddy } 507b5aa1006SYendapally Reddy Dhananjaya Reddy 508b5aa1006SYendapally Reddy Dhananjaya Reddy static const char *ns2_get_group_name(struct pinctrl_dev *pctrl_dev, 509b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int selector) 510b5aa1006SYendapally Reddy Dhananjaya Reddy { 511b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 512b5aa1006SYendapally Reddy Dhananjaya Reddy 513b5aa1006SYendapally Reddy Dhananjaya Reddy return pinctrl->groups[selector].name; 514b5aa1006SYendapally Reddy Dhananjaya Reddy } 515b5aa1006SYendapally Reddy Dhananjaya Reddy 516b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_get_group_pins(struct pinctrl_dev *pctrl_dev, 517b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int selector, const unsigned int **pins, 518b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int *num_pins) 519b5aa1006SYendapally Reddy Dhananjaya Reddy { 520b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 521b5aa1006SYendapally Reddy Dhananjaya Reddy 522b5aa1006SYendapally Reddy Dhananjaya Reddy *pins = pinctrl->groups[selector].pins; 523b5aa1006SYendapally Reddy Dhananjaya Reddy *num_pins = pinctrl->groups[selector].num_pins; 524b5aa1006SYendapally Reddy Dhananjaya Reddy 525b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 526b5aa1006SYendapally Reddy Dhananjaya Reddy } 527b5aa1006SYendapally Reddy Dhananjaya Reddy 528b5aa1006SYendapally Reddy Dhananjaya Reddy static void ns2_pin_dbg_show(struct pinctrl_dev *pctrl_dev, 529b5aa1006SYendapally Reddy Dhananjaya Reddy struct seq_file *s, unsigned int offset) 530b5aa1006SYendapally Reddy Dhananjaya Reddy { 531b5aa1006SYendapally Reddy Dhananjaya Reddy seq_printf(s, " %s", dev_name(pctrl_dev->dev)); 532b5aa1006SYendapally Reddy Dhananjaya Reddy } 533b5aa1006SYendapally Reddy Dhananjaya Reddy 534b5aa1006SYendapally Reddy Dhananjaya Reddy static struct pinctrl_ops ns2_pinctrl_ops = { 535b5aa1006SYendapally Reddy Dhananjaya Reddy .get_groups_count = ns2_get_groups_count, 536b5aa1006SYendapally Reddy Dhananjaya Reddy .get_group_name = ns2_get_group_name, 537b5aa1006SYendapally Reddy Dhananjaya Reddy .get_group_pins = ns2_get_group_pins, 538b5aa1006SYendapally Reddy Dhananjaya Reddy .pin_dbg_show = ns2_pin_dbg_show, 539b5aa1006SYendapally Reddy Dhananjaya Reddy .dt_node_to_map = pinconf_generic_dt_node_to_map_pin, 5409d814d41SArnd Bergmann .dt_free_map = pinctrl_utils_free_map, 541b5aa1006SYendapally Reddy Dhananjaya Reddy }; 542b5aa1006SYendapally Reddy Dhananjaya Reddy 543b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_get_functions_count(struct pinctrl_dev *pctrl_dev) 544b5aa1006SYendapally Reddy Dhananjaya Reddy { 545b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 546b5aa1006SYendapally Reddy Dhananjaya Reddy 547b5aa1006SYendapally Reddy Dhananjaya Reddy return pinctrl->num_functions; 548b5aa1006SYendapally Reddy Dhananjaya Reddy } 549b5aa1006SYendapally Reddy Dhananjaya Reddy 550b5aa1006SYendapally Reddy Dhananjaya Reddy static const char *ns2_get_function_name(struct pinctrl_dev *pctrl_dev, 551b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int selector) 552b5aa1006SYendapally Reddy Dhananjaya Reddy { 553b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 554b5aa1006SYendapally Reddy Dhananjaya Reddy 555b5aa1006SYendapally Reddy Dhananjaya Reddy return pinctrl->functions[selector].name; 556b5aa1006SYendapally Reddy Dhananjaya Reddy } 557b5aa1006SYendapally Reddy Dhananjaya Reddy 558b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_get_function_groups(struct pinctrl_dev *pctrl_dev, 559b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int selector, 560b5aa1006SYendapally Reddy Dhananjaya Reddy const char * const **groups, 561b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int * const num_groups) 562b5aa1006SYendapally Reddy Dhananjaya Reddy { 563b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 564b5aa1006SYendapally Reddy Dhananjaya Reddy 565b5aa1006SYendapally Reddy Dhananjaya Reddy *groups = pinctrl->functions[selector].groups; 566b5aa1006SYendapally Reddy Dhananjaya Reddy *num_groups = pinctrl->functions[selector].num_groups; 567b5aa1006SYendapally Reddy Dhananjaya Reddy 568b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 569b5aa1006SYendapally Reddy Dhananjaya Reddy } 570b5aa1006SYendapally Reddy Dhananjaya Reddy 571b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_pinmux_set(struct ns2_pinctrl *pinctrl, 572b5aa1006SYendapally Reddy Dhananjaya Reddy const struct ns2_pin_function *func, 573b5aa1006SYendapally Reddy Dhananjaya Reddy const struct ns2_pin_group *grp, 574b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_mux_log *mux_log) 575b5aa1006SYendapally Reddy Dhananjaya Reddy { 576b5aa1006SYendapally Reddy Dhananjaya Reddy const struct ns2_mux *mux = &grp->mux; 577b5aa1006SYendapally Reddy Dhananjaya Reddy int i; 578b5aa1006SYendapally Reddy Dhananjaya Reddy u32 val, mask; 579b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned long flags; 580b5aa1006SYendapally Reddy Dhananjaya Reddy void __iomem *base_address; 581b5aa1006SYendapally Reddy Dhananjaya Reddy 582b5aa1006SYendapally Reddy Dhananjaya Reddy for (i = 0; i < NS2_NUM_IOMUX; i++) { 583b5aa1006SYendapally Reddy Dhananjaya Reddy if ((mux->shift != mux_log[i].mux.shift) || 584b5aa1006SYendapally Reddy Dhananjaya Reddy (mux->base != mux_log[i].mux.base) || 585b5aa1006SYendapally Reddy Dhananjaya Reddy (mux->offset != mux_log[i].mux.offset)) 586b5aa1006SYendapally Reddy Dhananjaya Reddy continue; 587b5aa1006SYendapally Reddy Dhananjaya Reddy 588b5aa1006SYendapally Reddy Dhananjaya Reddy /* if this is a new configuration, just do it! */ 589b5aa1006SYendapally Reddy Dhananjaya Reddy if (!mux_log[i].is_configured) 590b5aa1006SYendapally Reddy Dhananjaya Reddy break; 591b5aa1006SYendapally Reddy Dhananjaya Reddy 592b5aa1006SYendapally Reddy Dhananjaya Reddy /* 593b5aa1006SYendapally Reddy Dhananjaya Reddy * IOMUX has been configured previously and one is trying to 594b5aa1006SYendapally Reddy Dhananjaya Reddy * configure it to a different function 595b5aa1006SYendapally Reddy Dhananjaya Reddy */ 596b5aa1006SYendapally Reddy Dhananjaya Reddy if (mux_log[i].mux.alt != mux->alt) { 597b5aa1006SYendapally Reddy Dhananjaya Reddy dev_err(pinctrl->dev, 598b5aa1006SYendapally Reddy Dhananjaya Reddy "double configuration error detected!\n"); 599b5aa1006SYendapally Reddy Dhananjaya Reddy dev_err(pinctrl->dev, "func:%s grp:%s\n", 600b5aa1006SYendapally Reddy Dhananjaya Reddy func->name, grp->name); 601b5aa1006SYendapally Reddy Dhananjaya Reddy return -EINVAL; 602b5aa1006SYendapally Reddy Dhananjaya Reddy } 603b5aa1006SYendapally Reddy Dhananjaya Reddy 604b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 605b5aa1006SYendapally Reddy Dhananjaya Reddy } 606b5aa1006SYendapally Reddy Dhananjaya Reddy if (i == NS2_NUM_IOMUX) 607b5aa1006SYendapally Reddy Dhananjaya Reddy return -EINVAL; 608b5aa1006SYendapally Reddy Dhananjaya Reddy 609b5aa1006SYendapally Reddy Dhananjaya Reddy mask = mux->mask; 610b5aa1006SYendapally Reddy Dhananjaya Reddy mux_log[i].mux.alt = mux->alt; 611b5aa1006SYendapally Reddy Dhananjaya Reddy mux_log[i].is_configured = true; 612b5aa1006SYendapally Reddy Dhananjaya Reddy 613b5aa1006SYendapally Reddy Dhananjaya Reddy switch (mux->base) { 614b5aa1006SYendapally Reddy Dhananjaya Reddy case NS2_PIN_MUX_BASE0: 615b5aa1006SYendapally Reddy Dhananjaya Reddy base_address = pinctrl->base0; 616b5aa1006SYendapally Reddy Dhananjaya Reddy break; 617b5aa1006SYendapally Reddy Dhananjaya Reddy 618b5aa1006SYendapally Reddy Dhananjaya Reddy case NS2_PIN_MUX_BASE1: 619b5aa1006SYendapally Reddy Dhananjaya Reddy base_address = pinctrl->base1; 620b5aa1006SYendapally Reddy Dhananjaya Reddy break; 621b5aa1006SYendapally Reddy Dhananjaya Reddy 622b5aa1006SYendapally Reddy Dhananjaya Reddy default: 623b5aa1006SYendapally Reddy Dhananjaya Reddy return -EINVAL; 624b5aa1006SYendapally Reddy Dhananjaya Reddy } 625b5aa1006SYendapally Reddy Dhananjaya Reddy 626b5aa1006SYendapally Reddy Dhananjaya Reddy spin_lock_irqsave(&pinctrl->lock, flags); 627b5aa1006SYendapally Reddy Dhananjaya Reddy val = readl(base_address + grp->mux.offset); 628b5aa1006SYendapally Reddy Dhananjaya Reddy val &= ~(mask << grp->mux.shift); 629b5aa1006SYendapally Reddy Dhananjaya Reddy val |= grp->mux.alt << grp->mux.shift; 630b5aa1006SYendapally Reddy Dhananjaya Reddy writel(val, (base_address + grp->mux.offset)); 631b5aa1006SYendapally Reddy Dhananjaya Reddy spin_unlock_irqrestore(&pinctrl->lock, flags); 632b5aa1006SYendapally Reddy Dhananjaya Reddy 633b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 634b5aa1006SYendapally Reddy Dhananjaya Reddy } 635b5aa1006SYendapally Reddy Dhananjaya Reddy 636b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_pinmux_enable(struct pinctrl_dev *pctrl_dev, 637b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int func_select, unsigned int grp_select) 638b5aa1006SYendapally Reddy Dhananjaya Reddy { 639b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 640b5aa1006SYendapally Reddy Dhananjaya Reddy const struct ns2_pin_function *func; 641b5aa1006SYendapally Reddy Dhananjaya Reddy const struct ns2_pin_group *grp; 642b5aa1006SYendapally Reddy Dhananjaya Reddy 643b5aa1006SYendapally Reddy Dhananjaya Reddy if (grp_select > pinctrl->num_groups || 644b5aa1006SYendapally Reddy Dhananjaya Reddy func_select > pinctrl->num_functions) 645b5aa1006SYendapally Reddy Dhananjaya Reddy return -EINVAL; 646b5aa1006SYendapally Reddy Dhananjaya Reddy 647b5aa1006SYendapally Reddy Dhananjaya Reddy func = &pinctrl->functions[func_select]; 648b5aa1006SYendapally Reddy Dhananjaya Reddy grp = &pinctrl->groups[grp_select]; 649b5aa1006SYendapally Reddy Dhananjaya Reddy 650b5aa1006SYendapally Reddy Dhananjaya Reddy dev_dbg(pctrl_dev->dev, "func:%u name:%s grp:%u name:%s\n", 651b5aa1006SYendapally Reddy Dhananjaya Reddy func_select, func->name, grp_select, grp->name); 652b5aa1006SYendapally Reddy Dhananjaya Reddy 653b5aa1006SYendapally Reddy Dhananjaya Reddy dev_dbg(pctrl_dev->dev, "offset:0x%08x shift:%u alt:%u\n", 654b5aa1006SYendapally Reddy Dhananjaya Reddy grp->mux.offset, grp->mux.shift, grp->mux.alt); 655b5aa1006SYendapally Reddy Dhananjaya Reddy 656b5aa1006SYendapally Reddy Dhananjaya Reddy return ns2_pinmux_set(pinctrl, func, grp, pinctrl->mux_log); 657b5aa1006SYendapally Reddy Dhananjaya Reddy } 658b5aa1006SYendapally Reddy Dhananjaya Reddy 659b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_pin_set_enable(struct pinctrl_dev *pctrldev, unsigned int pin, 660b5aa1006SYendapally Reddy Dhananjaya Reddy u16 enable) 661b5aa1006SYendapally Reddy Dhananjaya Reddy { 662b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); 663b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; 664b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned long flags; 665b5aa1006SYendapally Reddy Dhananjaya Reddy u32 val; 666b5aa1006SYendapally Reddy Dhananjaya Reddy void __iomem *base_address; 667b5aa1006SYendapally Reddy Dhananjaya Reddy 668b5aa1006SYendapally Reddy Dhananjaya Reddy base_address = pinctrl->pinconf_base; 669b5aa1006SYendapally Reddy Dhananjaya Reddy spin_lock_irqsave(&pinctrl->lock, flags); 670b5aa1006SYendapally Reddy Dhananjaya Reddy val = readl(base_address + pin_data->pin_conf.offset); 671b5aa1006SYendapally Reddy Dhananjaya Reddy val &= ~(NS2_PIN_SRC_MASK << pin_data->pin_conf.input_en); 672b5aa1006SYendapally Reddy Dhananjaya Reddy 673b5aa1006SYendapally Reddy Dhananjaya Reddy if (!enable) 674b5aa1006SYendapally Reddy Dhananjaya Reddy val |= NS2_PIN_INPUT_EN_MASK << pin_data->pin_conf.input_en; 675b5aa1006SYendapally Reddy Dhananjaya Reddy 676b5aa1006SYendapally Reddy Dhananjaya Reddy writel(val, (base_address + pin_data->pin_conf.offset)); 677b5aa1006SYendapally Reddy Dhananjaya Reddy spin_unlock_irqrestore(&pinctrl->lock, flags); 678b5aa1006SYendapally Reddy Dhananjaya Reddy 679b5aa1006SYendapally Reddy Dhananjaya Reddy dev_dbg(pctrldev->dev, "pin:%u set enable:%d\n", pin, enable); 680b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 681b5aa1006SYendapally Reddy Dhananjaya Reddy } 682b5aa1006SYendapally Reddy Dhananjaya Reddy 683b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_pin_get_enable(struct pinctrl_dev *pctrldev, unsigned int pin) 684b5aa1006SYendapally Reddy Dhananjaya Reddy { 685b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); 686b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; 687b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned long flags; 688b5aa1006SYendapally Reddy Dhananjaya Reddy int enable; 689b5aa1006SYendapally Reddy Dhananjaya Reddy 690b5aa1006SYendapally Reddy Dhananjaya Reddy spin_lock_irqsave(&pinctrl->lock, flags); 691b5aa1006SYendapally Reddy Dhananjaya Reddy enable = readl(pinctrl->pinconf_base + pin_data->pin_conf.offset); 692b5aa1006SYendapally Reddy Dhananjaya Reddy enable = (enable >> pin_data->pin_conf.input_en) & 693b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_INPUT_EN_MASK; 694b5aa1006SYendapally Reddy Dhananjaya Reddy spin_unlock_irqrestore(&pinctrl->lock, flags); 695b5aa1006SYendapally Reddy Dhananjaya Reddy 696b5aa1006SYendapally Reddy Dhananjaya Reddy if (!enable) 697b5aa1006SYendapally Reddy Dhananjaya Reddy enable = NS2_PIN_INPUT_EN_MASK; 698b5aa1006SYendapally Reddy Dhananjaya Reddy else 699b5aa1006SYendapally Reddy Dhananjaya Reddy enable = 0; 700b5aa1006SYendapally Reddy Dhananjaya Reddy 701b5aa1006SYendapally Reddy Dhananjaya Reddy dev_dbg(pctrldev->dev, "pin:%u get disable:%d\n", pin, enable); 702b5aa1006SYendapally Reddy Dhananjaya Reddy return enable; 703b5aa1006SYendapally Reddy Dhananjaya Reddy } 704b5aa1006SYendapally Reddy Dhananjaya Reddy 705b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_pin_set_slew(struct pinctrl_dev *pctrldev, unsigned int pin, 706b5aa1006SYendapally Reddy Dhananjaya Reddy u16 slew) 707b5aa1006SYendapally Reddy Dhananjaya Reddy { 708b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); 709b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; 710b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned long flags; 711b5aa1006SYendapally Reddy Dhananjaya Reddy u32 val; 712b5aa1006SYendapally Reddy Dhananjaya Reddy void __iomem *base_address; 713b5aa1006SYendapally Reddy Dhananjaya Reddy 714b5aa1006SYendapally Reddy Dhananjaya Reddy base_address = pinctrl->pinconf_base; 715b5aa1006SYendapally Reddy Dhananjaya Reddy spin_lock_irqsave(&pinctrl->lock, flags); 716b5aa1006SYendapally Reddy Dhananjaya Reddy val = readl(base_address + pin_data->pin_conf.offset); 717b5aa1006SYendapally Reddy Dhananjaya Reddy val &= ~(NS2_PIN_SRC_MASK << pin_data->pin_conf.src_shift); 718b5aa1006SYendapally Reddy Dhananjaya Reddy 719b5aa1006SYendapally Reddy Dhananjaya Reddy if (slew) 720b5aa1006SYendapally Reddy Dhananjaya Reddy val |= NS2_PIN_SRC_MASK << pin_data->pin_conf.src_shift; 721b5aa1006SYendapally Reddy Dhananjaya Reddy 722b5aa1006SYendapally Reddy Dhananjaya Reddy writel(val, (base_address + pin_data->pin_conf.offset)); 723b5aa1006SYendapally Reddy Dhananjaya Reddy spin_unlock_irqrestore(&pinctrl->lock, flags); 724b5aa1006SYendapally Reddy Dhananjaya Reddy 725b5aa1006SYendapally Reddy Dhananjaya Reddy dev_dbg(pctrldev->dev, "pin:%u set slew:%d\n", pin, slew); 726b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 727b5aa1006SYendapally Reddy Dhananjaya Reddy } 728b5aa1006SYendapally Reddy Dhananjaya Reddy 729b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_pin_get_slew(struct pinctrl_dev *pctrldev, unsigned int pin, 730b5aa1006SYendapally Reddy Dhananjaya Reddy u16 *slew) 731b5aa1006SYendapally Reddy Dhananjaya Reddy { 732b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); 733b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; 734b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned long flags; 735b5aa1006SYendapally Reddy Dhananjaya Reddy u32 val; 736b5aa1006SYendapally Reddy Dhananjaya Reddy 737b5aa1006SYendapally Reddy Dhananjaya Reddy spin_lock_irqsave(&pinctrl->lock, flags); 738b5aa1006SYendapally Reddy Dhananjaya Reddy val = readl(pinctrl->pinconf_base + pin_data->pin_conf.offset); 739b5aa1006SYendapally Reddy Dhananjaya Reddy *slew = (val >> pin_data->pin_conf.src_shift) & NS2_PIN_SRC_MASK; 740b5aa1006SYendapally Reddy Dhananjaya Reddy spin_unlock_irqrestore(&pinctrl->lock, flags); 741b5aa1006SYendapally Reddy Dhananjaya Reddy 742b5aa1006SYendapally Reddy Dhananjaya Reddy dev_dbg(pctrldev->dev, "pin:%u get slew:%d\n", pin, *slew); 743b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 744b5aa1006SYendapally Reddy Dhananjaya Reddy } 745b5aa1006SYendapally Reddy Dhananjaya Reddy 746b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_pin_set_pull(struct pinctrl_dev *pctrldev, unsigned int pin, 747b5aa1006SYendapally Reddy Dhananjaya Reddy bool pull_up, bool pull_down) 748b5aa1006SYendapally Reddy Dhananjaya Reddy { 749b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); 750b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; 751b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned long flags; 752b5aa1006SYendapally Reddy Dhananjaya Reddy u32 val; 753b5aa1006SYendapally Reddy Dhananjaya Reddy void __iomem *base_address; 754b5aa1006SYendapally Reddy Dhananjaya Reddy 755b5aa1006SYendapally Reddy Dhananjaya Reddy base_address = pinctrl->pinconf_base; 756b5aa1006SYendapally Reddy Dhananjaya Reddy spin_lock_irqsave(&pinctrl->lock, flags); 757b5aa1006SYendapally Reddy Dhananjaya Reddy val = readl(base_address + pin_data->pin_conf.offset); 758b5aa1006SYendapally Reddy Dhananjaya Reddy val &= ~(NS2_PIN_PULL_MASK << pin_data->pin_conf.pull_shift); 759b5aa1006SYendapally Reddy Dhananjaya Reddy 760b5aa1006SYendapally Reddy Dhananjaya Reddy if (pull_up == true) 761b5aa1006SYendapally Reddy Dhananjaya Reddy val |= NS2_PIN_PULL_UP << pin_data->pin_conf.pull_shift; 762b5aa1006SYendapally Reddy Dhananjaya Reddy if (pull_down == true) 763b5aa1006SYendapally Reddy Dhananjaya Reddy val |= NS2_PIN_PULL_DOWN << pin_data->pin_conf.pull_shift; 764b5aa1006SYendapally Reddy Dhananjaya Reddy writel(val, (base_address + pin_data->pin_conf.offset)); 765b5aa1006SYendapally Reddy Dhananjaya Reddy spin_unlock_irqrestore(&pinctrl->lock, flags); 766b5aa1006SYendapally Reddy Dhananjaya Reddy 767b5aa1006SYendapally Reddy Dhananjaya Reddy dev_dbg(pctrldev->dev, "pin:%u set pullup:%d pulldown: %d\n", 768b5aa1006SYendapally Reddy Dhananjaya Reddy pin, pull_up, pull_down); 769b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 770b5aa1006SYendapally Reddy Dhananjaya Reddy } 771b5aa1006SYendapally Reddy Dhananjaya Reddy 772b5aa1006SYendapally Reddy Dhananjaya Reddy static void ns2_pin_get_pull(struct pinctrl_dev *pctrldev, 773b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int pin, bool *pull_up, 774b5aa1006SYendapally Reddy Dhananjaya Reddy bool *pull_down) 775b5aa1006SYendapally Reddy Dhananjaya Reddy { 776b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); 777b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; 778b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned long flags; 779b5aa1006SYendapally Reddy Dhananjaya Reddy u32 val; 780b5aa1006SYendapally Reddy Dhananjaya Reddy 781b5aa1006SYendapally Reddy Dhananjaya Reddy spin_lock_irqsave(&pinctrl->lock, flags); 782b5aa1006SYendapally Reddy Dhananjaya Reddy val = readl(pinctrl->pinconf_base + pin_data->pin_conf.offset); 783b5aa1006SYendapally Reddy Dhananjaya Reddy val = (val >> pin_data->pin_conf.pull_shift) & NS2_PIN_PULL_MASK; 784b5aa1006SYendapally Reddy Dhananjaya Reddy *pull_up = false; 785b5aa1006SYendapally Reddy Dhananjaya Reddy *pull_down = false; 786b5aa1006SYendapally Reddy Dhananjaya Reddy 787b5aa1006SYendapally Reddy Dhananjaya Reddy if (val == NS2_PIN_PULL_UP) 788b5aa1006SYendapally Reddy Dhananjaya Reddy *pull_up = true; 789b5aa1006SYendapally Reddy Dhananjaya Reddy 790b5aa1006SYendapally Reddy Dhananjaya Reddy if (val == NS2_PIN_PULL_DOWN) 791b5aa1006SYendapally Reddy Dhananjaya Reddy *pull_down = true; 792b5aa1006SYendapally Reddy Dhananjaya Reddy spin_unlock_irqrestore(&pinctrl->lock, flags); 793b5aa1006SYendapally Reddy Dhananjaya Reddy } 794b5aa1006SYendapally Reddy Dhananjaya Reddy 795b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_pin_set_strength(struct pinctrl_dev *pctrldev, unsigned int pin, 796b5aa1006SYendapally Reddy Dhananjaya Reddy u16 strength) 797b5aa1006SYendapally Reddy Dhananjaya Reddy { 798b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); 799b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; 800b5aa1006SYendapally Reddy Dhananjaya Reddy u32 val; 801b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned long flags; 802b5aa1006SYendapally Reddy Dhananjaya Reddy void __iomem *base_address; 803b5aa1006SYendapally Reddy Dhananjaya Reddy 804b5aa1006SYendapally Reddy Dhananjaya Reddy /* make sure drive strength is supported */ 805b5aa1006SYendapally Reddy Dhananjaya Reddy if (strength < 2 || strength > 16 || (strength % 2)) 806b5aa1006SYendapally Reddy Dhananjaya Reddy return -ENOTSUPP; 807b5aa1006SYendapally Reddy Dhananjaya Reddy 808b5aa1006SYendapally Reddy Dhananjaya Reddy base_address = pinctrl->pinconf_base; 809b5aa1006SYendapally Reddy Dhananjaya Reddy spin_lock_irqsave(&pinctrl->lock, flags); 810b5aa1006SYendapally Reddy Dhananjaya Reddy val = readl(base_address + pin_data->pin_conf.offset); 811b5aa1006SYendapally Reddy Dhananjaya Reddy val &= ~(NS2_PIN_DRIVE_STRENGTH_MASK << pin_data->pin_conf.drive_shift); 812b5aa1006SYendapally Reddy Dhananjaya Reddy val |= ((strength / 2) - 1) << pin_data->pin_conf.drive_shift; 813b5aa1006SYendapally Reddy Dhananjaya Reddy writel(val, (base_address + pin_data->pin_conf.offset)); 814b5aa1006SYendapally Reddy Dhananjaya Reddy spin_unlock_irqrestore(&pinctrl->lock, flags); 815b5aa1006SYendapally Reddy Dhananjaya Reddy 816b5aa1006SYendapally Reddy Dhananjaya Reddy dev_dbg(pctrldev->dev, "pin:%u set drive strength:%d mA\n", 817b5aa1006SYendapally Reddy Dhananjaya Reddy pin, strength); 818b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 819b5aa1006SYendapally Reddy Dhananjaya Reddy } 820b5aa1006SYendapally Reddy Dhananjaya Reddy 821b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_pin_get_strength(struct pinctrl_dev *pctrldev, unsigned int pin, 822b5aa1006SYendapally Reddy Dhananjaya Reddy u16 *strength) 823b5aa1006SYendapally Reddy Dhananjaya Reddy { 824b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrldev); 825b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; 826b5aa1006SYendapally Reddy Dhananjaya Reddy u32 val; 827b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned long flags; 828b5aa1006SYendapally Reddy Dhananjaya Reddy 829b5aa1006SYendapally Reddy Dhananjaya Reddy spin_lock_irqsave(&pinctrl->lock, flags); 830b5aa1006SYendapally Reddy Dhananjaya Reddy val = readl(pinctrl->pinconf_base + pin_data->pin_conf.offset); 831b5aa1006SYendapally Reddy Dhananjaya Reddy *strength = (val >> pin_data->pin_conf.drive_shift) & 832b5aa1006SYendapally Reddy Dhananjaya Reddy NS2_PIN_DRIVE_STRENGTH_MASK; 833b5aa1006SYendapally Reddy Dhananjaya Reddy *strength = (*strength + 1) * 2; 834b5aa1006SYendapally Reddy Dhananjaya Reddy spin_unlock_irqrestore(&pinctrl->lock, flags); 835b5aa1006SYendapally Reddy Dhananjaya Reddy 836b5aa1006SYendapally Reddy Dhananjaya Reddy dev_dbg(pctrldev->dev, "pin:%u get drive strength:%d mA\n", 837b5aa1006SYendapally Reddy Dhananjaya Reddy pin, *strength); 838b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 839b5aa1006SYendapally Reddy Dhananjaya Reddy } 840b5aa1006SYendapally Reddy Dhananjaya Reddy 841b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_pin_config_get(struct pinctrl_dev *pctldev, unsigned int pin, 842b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned long *config) 843b5aa1006SYendapally Reddy Dhananjaya Reddy { 844b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pin *pin_data = pctldev->desc->pins[pin].drv_data; 845b5aa1006SYendapally Reddy Dhananjaya Reddy enum pin_config_param param = pinconf_to_config_param(*config); 846b5aa1006SYendapally Reddy Dhananjaya Reddy bool pull_up, pull_down; 847b5aa1006SYendapally Reddy Dhananjaya Reddy u16 arg = 0; 848b5aa1006SYendapally Reddy Dhananjaya Reddy int ret; 849b5aa1006SYendapally Reddy Dhananjaya Reddy 850b5aa1006SYendapally Reddy Dhananjaya Reddy if (pin_data->pin_conf.base == -1) 851b5aa1006SYendapally Reddy Dhananjaya Reddy return -ENOTSUPP; 852b5aa1006SYendapally Reddy Dhananjaya Reddy 853b5aa1006SYendapally Reddy Dhananjaya Reddy switch (param) { 854b5aa1006SYendapally Reddy Dhananjaya Reddy case PIN_CONFIG_BIAS_DISABLE: 855b5aa1006SYendapally Reddy Dhananjaya Reddy ns2_pin_get_pull(pctldev, pin, &pull_up, &pull_down); 856b5aa1006SYendapally Reddy Dhananjaya Reddy if ((pull_up == false) && (pull_down == false)) 857b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 858b5aa1006SYendapally Reddy Dhananjaya Reddy else 859b5aa1006SYendapally Reddy Dhananjaya Reddy return -EINVAL; 860b5aa1006SYendapally Reddy Dhananjaya Reddy 861b5aa1006SYendapally Reddy Dhananjaya Reddy case PIN_CONFIG_BIAS_PULL_UP: 862b5aa1006SYendapally Reddy Dhananjaya Reddy ns2_pin_get_pull(pctldev, pin, &pull_up, &pull_down); 863b5aa1006SYendapally Reddy Dhananjaya Reddy if (pull_up) 864b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 865b5aa1006SYendapally Reddy Dhananjaya Reddy else 866b5aa1006SYendapally Reddy Dhananjaya Reddy return -EINVAL; 867b5aa1006SYendapally Reddy Dhananjaya Reddy 868b5aa1006SYendapally Reddy Dhananjaya Reddy case PIN_CONFIG_BIAS_PULL_DOWN: 869b5aa1006SYendapally Reddy Dhananjaya Reddy ns2_pin_get_pull(pctldev, pin, &pull_up, &pull_down); 870b5aa1006SYendapally Reddy Dhananjaya Reddy if (pull_down) 871b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 872b5aa1006SYendapally Reddy Dhananjaya Reddy else 873b5aa1006SYendapally Reddy Dhananjaya Reddy return -EINVAL; 874b5aa1006SYendapally Reddy Dhananjaya Reddy 875b5aa1006SYendapally Reddy Dhananjaya Reddy case PIN_CONFIG_DRIVE_STRENGTH: 876b5aa1006SYendapally Reddy Dhananjaya Reddy ret = ns2_pin_get_strength(pctldev, pin, &arg); 877b5aa1006SYendapally Reddy Dhananjaya Reddy if (ret) 878b5aa1006SYendapally Reddy Dhananjaya Reddy return ret; 879b5aa1006SYendapally Reddy Dhananjaya Reddy *config = pinconf_to_config_packed(param, arg); 880b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 881b5aa1006SYendapally Reddy Dhananjaya Reddy 882b5aa1006SYendapally Reddy Dhananjaya Reddy case PIN_CONFIG_SLEW_RATE: 883b5aa1006SYendapally Reddy Dhananjaya Reddy ret = ns2_pin_get_slew(pctldev, pin, &arg); 884b5aa1006SYendapally Reddy Dhananjaya Reddy if (ret) 885b5aa1006SYendapally Reddy Dhananjaya Reddy return ret; 886b5aa1006SYendapally Reddy Dhananjaya Reddy *config = pinconf_to_config_packed(param, arg); 887b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 888b5aa1006SYendapally Reddy Dhananjaya Reddy 889b5aa1006SYendapally Reddy Dhananjaya Reddy case PIN_CONFIG_INPUT_ENABLE: 890b5aa1006SYendapally Reddy Dhananjaya Reddy ret = ns2_pin_get_enable(pctldev, pin); 891b5aa1006SYendapally Reddy Dhananjaya Reddy if (ret) 892b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 893b5aa1006SYendapally Reddy Dhananjaya Reddy else 894b5aa1006SYendapally Reddy Dhananjaya Reddy return -EINVAL; 895b5aa1006SYendapally Reddy Dhananjaya Reddy 896b5aa1006SYendapally Reddy Dhananjaya Reddy default: 897b5aa1006SYendapally Reddy Dhananjaya Reddy return -ENOTSUPP; 898b5aa1006SYendapally Reddy Dhananjaya Reddy } 899b5aa1006SYendapally Reddy Dhananjaya Reddy } 900b5aa1006SYendapally Reddy Dhananjaya Reddy 901b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_pin_config_set(struct pinctrl_dev *pctrldev, unsigned int pin, 902b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned long *configs, unsigned int num_configs) 903b5aa1006SYendapally Reddy Dhananjaya Reddy { 904b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pin *pin_data = pctrldev->desc->pins[pin].drv_data; 905b5aa1006SYendapally Reddy Dhananjaya Reddy enum pin_config_param param; 906b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int i; 907b5aa1006SYendapally Reddy Dhananjaya Reddy u16 arg; 908b5aa1006SYendapally Reddy Dhananjaya Reddy int ret = -ENOTSUPP; 909b5aa1006SYendapally Reddy Dhananjaya Reddy 910b5aa1006SYendapally Reddy Dhananjaya Reddy if (pin_data->pin_conf.base == -1) 911b5aa1006SYendapally Reddy Dhananjaya Reddy return -ENOTSUPP; 912b5aa1006SYendapally Reddy Dhananjaya Reddy 913b5aa1006SYendapally Reddy Dhananjaya Reddy for (i = 0; i < num_configs; i++) { 914b5aa1006SYendapally Reddy Dhananjaya Reddy param = pinconf_to_config_param(configs[i]); 915b5aa1006SYendapally Reddy Dhananjaya Reddy arg = pinconf_to_config_argument(configs[i]); 916b5aa1006SYendapally Reddy Dhananjaya Reddy 917b5aa1006SYendapally Reddy Dhananjaya Reddy switch (param) { 918b5aa1006SYendapally Reddy Dhananjaya Reddy case PIN_CONFIG_BIAS_DISABLE: 919b5aa1006SYendapally Reddy Dhananjaya Reddy ret = ns2_pin_set_pull(pctrldev, pin, false, false); 920b5aa1006SYendapally Reddy Dhananjaya Reddy if (ret < 0) 921b5aa1006SYendapally Reddy Dhananjaya Reddy goto out; 922b5aa1006SYendapally Reddy Dhananjaya Reddy break; 923b5aa1006SYendapally Reddy Dhananjaya Reddy 924b5aa1006SYendapally Reddy Dhananjaya Reddy case PIN_CONFIG_BIAS_PULL_UP: 925b5aa1006SYendapally Reddy Dhananjaya Reddy ret = ns2_pin_set_pull(pctrldev, pin, true, false); 926b5aa1006SYendapally Reddy Dhananjaya Reddy if (ret < 0) 927b5aa1006SYendapally Reddy Dhananjaya Reddy goto out; 928b5aa1006SYendapally Reddy Dhananjaya Reddy break; 929b5aa1006SYendapally Reddy Dhananjaya Reddy 930b5aa1006SYendapally Reddy Dhananjaya Reddy case PIN_CONFIG_BIAS_PULL_DOWN: 931b5aa1006SYendapally Reddy Dhananjaya Reddy ret = ns2_pin_set_pull(pctrldev, pin, false, true); 932b5aa1006SYendapally Reddy Dhananjaya Reddy if (ret < 0) 933b5aa1006SYendapally Reddy Dhananjaya Reddy goto out; 934b5aa1006SYendapally Reddy Dhananjaya Reddy break; 935b5aa1006SYendapally Reddy Dhananjaya Reddy 936b5aa1006SYendapally Reddy Dhananjaya Reddy case PIN_CONFIG_DRIVE_STRENGTH: 937b5aa1006SYendapally Reddy Dhananjaya Reddy ret = ns2_pin_set_strength(pctrldev, pin, arg); 938b5aa1006SYendapally Reddy Dhananjaya Reddy if (ret < 0) 939b5aa1006SYendapally Reddy Dhananjaya Reddy goto out; 940b5aa1006SYendapally Reddy Dhananjaya Reddy break; 941b5aa1006SYendapally Reddy Dhananjaya Reddy 942b5aa1006SYendapally Reddy Dhananjaya Reddy case PIN_CONFIG_SLEW_RATE: 943b5aa1006SYendapally Reddy Dhananjaya Reddy ret = ns2_pin_set_slew(pctrldev, pin, arg); 944b5aa1006SYendapally Reddy Dhananjaya Reddy if (ret < 0) 945b5aa1006SYendapally Reddy Dhananjaya Reddy goto out; 946b5aa1006SYendapally Reddy Dhananjaya Reddy break; 947b5aa1006SYendapally Reddy Dhananjaya Reddy 948b5aa1006SYendapally Reddy Dhananjaya Reddy case PIN_CONFIG_INPUT_ENABLE: 949b5aa1006SYendapally Reddy Dhananjaya Reddy ret = ns2_pin_set_enable(pctrldev, pin, arg); 950b5aa1006SYendapally Reddy Dhananjaya Reddy if (ret < 0) 951b5aa1006SYendapally Reddy Dhananjaya Reddy goto out; 952b5aa1006SYendapally Reddy Dhananjaya Reddy break; 953b5aa1006SYendapally Reddy Dhananjaya Reddy 954b5aa1006SYendapally Reddy Dhananjaya Reddy default: 955b5aa1006SYendapally Reddy Dhananjaya Reddy dev_err(pctrldev->dev, "invalid configuration\n"); 956b5aa1006SYendapally Reddy Dhananjaya Reddy return -ENOTSUPP; 957b5aa1006SYendapally Reddy Dhananjaya Reddy } 958b5aa1006SYendapally Reddy Dhananjaya Reddy } 959b5aa1006SYendapally Reddy Dhananjaya Reddy out: 960b5aa1006SYendapally Reddy Dhananjaya Reddy return ret; 961b5aa1006SYendapally Reddy Dhananjaya Reddy } 962b5aa1006SYendapally Reddy Dhananjaya Reddy static struct pinmux_ops ns2_pinmux_ops = { 963b5aa1006SYendapally Reddy Dhananjaya Reddy .get_functions_count = ns2_get_functions_count, 964b5aa1006SYendapally Reddy Dhananjaya Reddy .get_function_name = ns2_get_function_name, 965b5aa1006SYendapally Reddy Dhananjaya Reddy .get_function_groups = ns2_get_function_groups, 966b5aa1006SYendapally Reddy Dhananjaya Reddy .set_mux = ns2_pinmux_enable, 967b5aa1006SYendapally Reddy Dhananjaya Reddy }; 968b5aa1006SYendapally Reddy Dhananjaya Reddy 969b5aa1006SYendapally Reddy Dhananjaya Reddy static const struct pinconf_ops ns2_pinconf_ops = { 970b5aa1006SYendapally Reddy Dhananjaya Reddy .is_generic = true, 971b5aa1006SYendapally Reddy Dhananjaya Reddy .pin_config_get = ns2_pin_config_get, 972b5aa1006SYendapally Reddy Dhananjaya Reddy .pin_config_set = ns2_pin_config_set, 973b5aa1006SYendapally Reddy Dhananjaya Reddy }; 974b5aa1006SYendapally Reddy Dhananjaya Reddy 975b5aa1006SYendapally Reddy Dhananjaya Reddy static struct pinctrl_desc ns2_pinctrl_desc = { 976b5aa1006SYendapally Reddy Dhananjaya Reddy .name = "ns2-pinmux", 977b5aa1006SYendapally Reddy Dhananjaya Reddy .pctlops = &ns2_pinctrl_ops, 978b5aa1006SYendapally Reddy Dhananjaya Reddy .pmxops = &ns2_pinmux_ops, 979b5aa1006SYendapally Reddy Dhananjaya Reddy .confops = &ns2_pinconf_ops, 980b5aa1006SYendapally Reddy Dhananjaya Reddy }; 981b5aa1006SYendapally Reddy Dhananjaya Reddy 982b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_mux_log_init(struct ns2_pinctrl *pinctrl) 983b5aa1006SYendapally Reddy Dhananjaya Reddy { 984b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_mux_log *log; 985b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int i; 986b5aa1006SYendapally Reddy Dhananjaya Reddy 987b5aa1006SYendapally Reddy Dhananjaya Reddy pinctrl->mux_log = devm_kcalloc(pinctrl->dev, NS2_NUM_IOMUX, 988b5aa1006SYendapally Reddy Dhananjaya Reddy sizeof(struct ns2_mux_log), 989b5aa1006SYendapally Reddy Dhananjaya Reddy GFP_KERNEL); 990b5aa1006SYendapally Reddy Dhananjaya Reddy if (!pinctrl->mux_log) 991b5aa1006SYendapally Reddy Dhananjaya Reddy return -ENOMEM; 992b5aa1006SYendapally Reddy Dhananjaya Reddy 993b5aa1006SYendapally Reddy Dhananjaya Reddy for (i = 0; i < NS2_NUM_IOMUX; i++) 994b5aa1006SYendapally Reddy Dhananjaya Reddy pinctrl->mux_log[i].is_configured = false; 995b5aa1006SYendapally Reddy Dhananjaya Reddy /* Group 0 uses bit 31 in the IOMUX_PAD_FUNCTION_0 register */ 996b5aa1006SYendapally Reddy Dhananjaya Reddy log = &pinctrl->mux_log[0]; 997b5aa1006SYendapally Reddy Dhananjaya Reddy log->mux.base = NS2_PIN_MUX_BASE0; 998b5aa1006SYendapally Reddy Dhananjaya Reddy log->mux.offset = 0; 999b5aa1006SYendapally Reddy Dhananjaya Reddy log->mux.shift = 31; 1000b5aa1006SYendapally Reddy Dhananjaya Reddy log->mux.alt = 0; 1001b5aa1006SYendapally Reddy Dhananjaya Reddy 1002b5aa1006SYendapally Reddy Dhananjaya Reddy /* 1003b5aa1006SYendapally Reddy Dhananjaya Reddy * Groups 1 through 14 use two bits each in the 1004b5aa1006SYendapally Reddy Dhananjaya Reddy * IOMUX_PAD_FUNCTION_1 register starting with 1005b5aa1006SYendapally Reddy Dhananjaya Reddy * bit position 30. 1006b5aa1006SYendapally Reddy Dhananjaya Reddy */ 1007b5aa1006SYendapally Reddy Dhananjaya Reddy for (i = 1; i < (NS2_NUM_IOMUX - NS2_NUM_PWM_MUX); i++) { 1008b5aa1006SYendapally Reddy Dhananjaya Reddy log = &pinctrl->mux_log[i]; 1009b5aa1006SYendapally Reddy Dhananjaya Reddy log->mux.base = NS2_PIN_MUX_BASE0; 1010b5aa1006SYendapally Reddy Dhananjaya Reddy log->mux.offset = NS2_MUX_PAD_FUNC1_OFFSET; 1011b5aa1006SYendapally Reddy Dhananjaya Reddy log->mux.shift = 32 - (i * 2); 1012b5aa1006SYendapally Reddy Dhananjaya Reddy log->mux.alt = 0; 1013b5aa1006SYendapally Reddy Dhananjaya Reddy } 1014b5aa1006SYendapally Reddy Dhananjaya Reddy 1015b5aa1006SYendapally Reddy Dhananjaya Reddy /* 1016b5aa1006SYendapally Reddy Dhananjaya Reddy * Groups 15 through 18 use one bit each in the 1017b5aa1006SYendapally Reddy Dhananjaya Reddy * AUX_SEL register. 1018b5aa1006SYendapally Reddy Dhananjaya Reddy */ 1019b5aa1006SYendapally Reddy Dhananjaya Reddy for (i = 0; i < NS2_NUM_PWM_MUX; i++) { 1020b5aa1006SYendapally Reddy Dhananjaya Reddy log = &pinctrl->mux_log[(NS2_NUM_IOMUX - NS2_NUM_PWM_MUX) + i]; 1021b5aa1006SYendapally Reddy Dhananjaya Reddy log->mux.base = NS2_PIN_MUX_BASE1; 1022b5aa1006SYendapally Reddy Dhananjaya Reddy log->mux.offset = 0; 1023b5aa1006SYendapally Reddy Dhananjaya Reddy log->mux.shift = i; 1024b5aa1006SYendapally Reddy Dhananjaya Reddy log->mux.alt = 0; 1025b5aa1006SYendapally Reddy Dhananjaya Reddy } 1026b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 1027b5aa1006SYendapally Reddy Dhananjaya Reddy } 1028b5aa1006SYendapally Reddy Dhananjaya Reddy 1029b5aa1006SYendapally Reddy Dhananjaya Reddy static int ns2_pinmux_probe(struct platform_device *pdev) 1030b5aa1006SYendapally Reddy Dhananjaya Reddy { 1031b5aa1006SYendapally Reddy Dhananjaya Reddy struct ns2_pinctrl *pinctrl; 1032b5aa1006SYendapally Reddy Dhananjaya Reddy struct resource *res; 1033b5aa1006SYendapally Reddy Dhananjaya Reddy int i, ret; 1034b5aa1006SYendapally Reddy Dhananjaya Reddy struct pinctrl_pin_desc *pins; 1035b5aa1006SYendapally Reddy Dhananjaya Reddy unsigned int num_pins = ARRAY_SIZE(ns2_pins); 1036b5aa1006SYendapally Reddy Dhananjaya Reddy 1037b5aa1006SYendapally Reddy Dhananjaya Reddy pinctrl = devm_kzalloc(&pdev->dev, sizeof(*pinctrl), GFP_KERNEL); 1038b5aa1006SYendapally Reddy Dhananjaya Reddy if (!pinctrl) 1039b5aa1006SYendapally Reddy Dhananjaya Reddy return -ENOMEM; 1040b5aa1006SYendapally Reddy Dhananjaya Reddy 1041b5aa1006SYendapally Reddy Dhananjaya Reddy pinctrl->dev = &pdev->dev; 1042b5aa1006SYendapally Reddy Dhananjaya Reddy platform_set_drvdata(pdev, pinctrl); 1043b5aa1006SYendapally Reddy Dhananjaya Reddy spin_lock_init(&pinctrl->lock); 1044b5aa1006SYendapally Reddy Dhananjaya Reddy 1045b5aa1006SYendapally Reddy Dhananjaya Reddy res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1046b5aa1006SYendapally Reddy Dhananjaya Reddy pinctrl->base0 = devm_ioremap_resource(&pdev->dev, res); 1047b5aa1006SYendapally Reddy Dhananjaya Reddy if (IS_ERR(pinctrl->base0)) { 1048b5aa1006SYendapally Reddy Dhananjaya Reddy dev_err(&pdev->dev, "unable to map I/O space\n"); 1049b5aa1006SYendapally Reddy Dhananjaya Reddy return PTR_ERR(pinctrl->base0); 1050b5aa1006SYendapally Reddy Dhananjaya Reddy } 1051b5aa1006SYendapally Reddy Dhananjaya Reddy 1052b5aa1006SYendapally Reddy Dhananjaya Reddy res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1053b5aa1006SYendapally Reddy Dhananjaya Reddy pinctrl->base1 = devm_ioremap_nocache(&pdev->dev, res->start, 1054b5aa1006SYendapally Reddy Dhananjaya Reddy resource_size(res)); 1055b5aa1006SYendapally Reddy Dhananjaya Reddy if (!pinctrl->base1) { 1056b5aa1006SYendapally Reddy Dhananjaya Reddy dev_err(&pdev->dev, "unable to map I/O space\n"); 1057b5aa1006SYendapally Reddy Dhananjaya Reddy return -ENOMEM; 1058b5aa1006SYendapally Reddy Dhananjaya Reddy } 1059b5aa1006SYendapally Reddy Dhananjaya Reddy 1060b5aa1006SYendapally Reddy Dhananjaya Reddy res = platform_get_resource(pdev, IORESOURCE_MEM, 2); 1061b5aa1006SYendapally Reddy Dhananjaya Reddy pinctrl->pinconf_base = devm_ioremap_resource(&pdev->dev, res); 1062b5aa1006SYendapally Reddy Dhananjaya Reddy if (IS_ERR(pinctrl->pinconf_base)) { 1063b5aa1006SYendapally Reddy Dhananjaya Reddy dev_err(&pdev->dev, "unable to map I/O space\n"); 1064b5aa1006SYendapally Reddy Dhananjaya Reddy return PTR_ERR(pinctrl->pinconf_base); 1065b5aa1006SYendapally Reddy Dhananjaya Reddy } 1066b5aa1006SYendapally Reddy Dhananjaya Reddy 1067b5aa1006SYendapally Reddy Dhananjaya Reddy ret = ns2_mux_log_init(pinctrl); 1068b5aa1006SYendapally Reddy Dhananjaya Reddy if (ret) { 1069b5aa1006SYendapally Reddy Dhananjaya Reddy dev_err(&pdev->dev, "unable to initialize IOMUX log\n"); 1070b5aa1006SYendapally Reddy Dhananjaya Reddy return ret; 1071b5aa1006SYendapally Reddy Dhananjaya Reddy } 1072b5aa1006SYendapally Reddy Dhananjaya Reddy 1073b5aa1006SYendapally Reddy Dhananjaya Reddy pins = devm_kcalloc(&pdev->dev, num_pins, sizeof(*pins), GFP_KERNEL); 1074b5aa1006SYendapally Reddy Dhananjaya Reddy if (!pins) 1075b5aa1006SYendapally Reddy Dhananjaya Reddy return -ENOMEM; 1076b5aa1006SYendapally Reddy Dhananjaya Reddy 1077b5aa1006SYendapally Reddy Dhananjaya Reddy for (i = 0; i < num_pins; i++) { 1078b5aa1006SYendapally Reddy Dhananjaya Reddy pins[i].number = ns2_pins[i].pin; 1079b5aa1006SYendapally Reddy Dhananjaya Reddy pins[i].name = ns2_pins[i].name; 1080b5aa1006SYendapally Reddy Dhananjaya Reddy pins[i].drv_data = &ns2_pins[i]; 1081b5aa1006SYendapally Reddy Dhananjaya Reddy } 1082b5aa1006SYendapally Reddy Dhananjaya Reddy 1083b5aa1006SYendapally Reddy Dhananjaya Reddy pinctrl->groups = ns2_pin_groups; 1084b5aa1006SYendapally Reddy Dhananjaya Reddy pinctrl->num_groups = ARRAY_SIZE(ns2_pin_groups); 1085b5aa1006SYendapally Reddy Dhananjaya Reddy pinctrl->functions = ns2_pin_functions; 1086b5aa1006SYendapally Reddy Dhananjaya Reddy pinctrl->num_functions = ARRAY_SIZE(ns2_pin_functions); 1087b5aa1006SYendapally Reddy Dhananjaya Reddy ns2_pinctrl_desc.pins = pins; 1088b5aa1006SYendapally Reddy Dhananjaya Reddy ns2_pinctrl_desc.npins = num_pins; 1089b5aa1006SYendapally Reddy Dhananjaya Reddy 1090b5aa1006SYendapally Reddy Dhananjaya Reddy pinctrl->pctl = pinctrl_register(&ns2_pinctrl_desc, &pdev->dev, 1091b5aa1006SYendapally Reddy Dhananjaya Reddy pinctrl); 1092aeb8753bSWei Yongjun if (IS_ERR(pinctrl->pctl)) { 1093b5aa1006SYendapally Reddy Dhananjaya Reddy dev_err(&pdev->dev, "unable to register IOMUX pinctrl\n"); 1094aeb8753bSWei Yongjun return PTR_ERR(pinctrl->pctl); 1095b5aa1006SYendapally Reddy Dhananjaya Reddy } 1096b5aa1006SYendapally Reddy Dhananjaya Reddy 1097b5aa1006SYendapally Reddy Dhananjaya Reddy return 0; 1098b5aa1006SYendapally Reddy Dhananjaya Reddy } 1099b5aa1006SYendapally Reddy Dhananjaya Reddy 1100b5aa1006SYendapally Reddy Dhananjaya Reddy static const struct of_device_id ns2_pinmux_of_match[] = { 1101b5aa1006SYendapally Reddy Dhananjaya Reddy {.compatible = "brcm,ns2-pinmux"}, 1102b5aa1006SYendapally Reddy Dhananjaya Reddy { } 1103b5aa1006SYendapally Reddy Dhananjaya Reddy }; 1104b5aa1006SYendapally Reddy Dhananjaya Reddy 1105b5aa1006SYendapally Reddy Dhananjaya Reddy static struct platform_driver ns2_pinmux_driver = { 1106b5aa1006SYendapally Reddy Dhananjaya Reddy .driver = { 1107b5aa1006SYendapally Reddy Dhananjaya Reddy .name = "ns2-pinmux", 1108b5aa1006SYendapally Reddy Dhananjaya Reddy .of_match_table = ns2_pinmux_of_match, 1109b5aa1006SYendapally Reddy Dhananjaya Reddy }, 1110b5aa1006SYendapally Reddy Dhananjaya Reddy .probe = ns2_pinmux_probe, 1111b5aa1006SYendapally Reddy Dhananjaya Reddy }; 1112b5aa1006SYendapally Reddy Dhananjaya Reddy 1113b5aa1006SYendapally Reddy Dhananjaya Reddy static int __init ns2_pinmux_init(void) 1114b5aa1006SYendapally Reddy Dhananjaya Reddy { 1115b5aa1006SYendapally Reddy Dhananjaya Reddy return platform_driver_register(&ns2_pinmux_driver); 1116b5aa1006SYendapally Reddy Dhananjaya Reddy } 1117b5aa1006SYendapally Reddy Dhananjaya Reddy arch_initcall(ns2_pinmux_init); 1118