18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (C) 2014-2017 Broadcom 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or 58c2ecf20Sopenharmony_ci * modify it under the terms of the GNU General Public License as 68c2ecf20Sopenharmony_ci * published by the Free Software Foundation version 2. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * This program is distributed "as is" WITHOUT ANY WARRANTY of any 98c2ecf20Sopenharmony_ci * kind, whether express or implied; without even the implied warranty 108c2ecf20Sopenharmony_ci * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 118c2ecf20Sopenharmony_ci * GNU General Public License for more details. 128c2ecf20Sopenharmony_ci */ 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* 158c2ecf20Sopenharmony_ci * Broadcom Cygnus IOMUX driver 168c2ecf20Sopenharmony_ci * 178c2ecf20Sopenharmony_ci * This file contains the Cygnus IOMUX driver that supports group based PINMUX 188c2ecf20Sopenharmony_ci * configuration. Although PINMUX configuration is mainly group based, the 198c2ecf20Sopenharmony_ci * Cygnus IOMUX controller allows certain pins to be individually muxed to GPIO 208c2ecf20Sopenharmony_ci * function, and therefore be controlled by the Cygnus ASIU GPIO controller 218c2ecf20Sopenharmony_ci */ 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#include <linux/err.h> 248c2ecf20Sopenharmony_ci#include <linux/io.h> 258c2ecf20Sopenharmony_ci#include <linux/of.h> 268c2ecf20Sopenharmony_ci#include <linux/slab.h> 278c2ecf20Sopenharmony_ci#include <linux/platform_device.h> 288c2ecf20Sopenharmony_ci#include <linux/pinctrl/pinctrl.h> 298c2ecf20Sopenharmony_ci#include <linux/pinctrl/pinmux.h> 308c2ecf20Sopenharmony_ci#include <linux/pinctrl/pinconf.h> 318c2ecf20Sopenharmony_ci#include <linux/pinctrl/pinconf-generic.h> 328c2ecf20Sopenharmony_ci#include "../core.h" 338c2ecf20Sopenharmony_ci#include "../pinctrl-utils.h" 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#define CYGNUS_NUM_IOMUX_REGS 8 368c2ecf20Sopenharmony_ci#define CYGNUS_NUM_MUX_PER_REG 8 378c2ecf20Sopenharmony_ci#define CYGNUS_NUM_IOMUX (CYGNUS_NUM_IOMUX_REGS * \ 388c2ecf20Sopenharmony_ci CYGNUS_NUM_MUX_PER_REG) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/* 418c2ecf20Sopenharmony_ci * Cygnus IOMUX register description 428c2ecf20Sopenharmony_ci * 438c2ecf20Sopenharmony_ci * @offset: register offset for mux configuration of a group 448c2ecf20Sopenharmony_ci * @shift: bit shift for mux configuration of a group 458c2ecf20Sopenharmony_ci * @alt: alternate function to set to 468c2ecf20Sopenharmony_ci */ 478c2ecf20Sopenharmony_cistruct cygnus_mux { 488c2ecf20Sopenharmony_ci unsigned int offset; 498c2ecf20Sopenharmony_ci unsigned int shift; 508c2ecf20Sopenharmony_ci unsigned int alt; 518c2ecf20Sopenharmony_ci}; 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci/* 548c2ecf20Sopenharmony_ci * Keep track of Cygnus IOMUX configuration and prevent double configuration 558c2ecf20Sopenharmony_ci * 568c2ecf20Sopenharmony_ci * @cygnus_mux: Cygnus IOMUX register description 578c2ecf20Sopenharmony_ci * @is_configured: flag to indicate whether a mux setting has already been 588c2ecf20Sopenharmony_ci * configured 598c2ecf20Sopenharmony_ci */ 608c2ecf20Sopenharmony_cistruct cygnus_mux_log { 618c2ecf20Sopenharmony_ci struct cygnus_mux mux; 628c2ecf20Sopenharmony_ci bool is_configured; 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* 668c2ecf20Sopenharmony_ci * Group based IOMUX configuration 678c2ecf20Sopenharmony_ci * 688c2ecf20Sopenharmony_ci * @name: name of the group 698c2ecf20Sopenharmony_ci * @pins: array of pins used by this group 708c2ecf20Sopenharmony_ci * @num_pins: total number of pins used by this group 718c2ecf20Sopenharmony_ci * @mux: Cygnus group based IOMUX configuration 728c2ecf20Sopenharmony_ci */ 738c2ecf20Sopenharmony_cistruct cygnus_pin_group { 748c2ecf20Sopenharmony_ci const char *name; 758c2ecf20Sopenharmony_ci const unsigned *pins; 768c2ecf20Sopenharmony_ci unsigned num_pins; 778c2ecf20Sopenharmony_ci struct cygnus_mux mux; 788c2ecf20Sopenharmony_ci}; 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci/* 818c2ecf20Sopenharmony_ci * Cygnus mux function and supported pin groups 828c2ecf20Sopenharmony_ci * 838c2ecf20Sopenharmony_ci * @name: name of the function 848c2ecf20Sopenharmony_ci * @groups: array of groups that can be supported by this function 858c2ecf20Sopenharmony_ci * @num_groups: total number of groups that can be supported by this function 868c2ecf20Sopenharmony_ci */ 878c2ecf20Sopenharmony_cistruct cygnus_pin_function { 888c2ecf20Sopenharmony_ci const char *name; 898c2ecf20Sopenharmony_ci const char * const *groups; 908c2ecf20Sopenharmony_ci unsigned num_groups; 918c2ecf20Sopenharmony_ci}; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/* 948c2ecf20Sopenharmony_ci * Cygnus IOMUX pinctrl core 958c2ecf20Sopenharmony_ci * 968c2ecf20Sopenharmony_ci * @pctl: pointer to pinctrl_dev 978c2ecf20Sopenharmony_ci * @dev: pointer to device 988c2ecf20Sopenharmony_ci * @base0: first I/O register base of the Cygnus IOMUX controller 998c2ecf20Sopenharmony_ci * @base1: second I/O register base 1008c2ecf20Sopenharmony_ci * @groups: pointer to array of groups 1018c2ecf20Sopenharmony_ci * @num_groups: total number of groups 1028c2ecf20Sopenharmony_ci * @functions: pointer to array of functions 1038c2ecf20Sopenharmony_ci * @num_functions: total number of functions 1048c2ecf20Sopenharmony_ci * @mux_log: pointer to the array of mux logs 1058c2ecf20Sopenharmony_ci * @lock: lock to protect register access 1068c2ecf20Sopenharmony_ci */ 1078c2ecf20Sopenharmony_cistruct cygnus_pinctrl { 1088c2ecf20Sopenharmony_ci struct pinctrl_dev *pctl; 1098c2ecf20Sopenharmony_ci struct device *dev; 1108c2ecf20Sopenharmony_ci void __iomem *base0; 1118c2ecf20Sopenharmony_ci void __iomem *base1; 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci const struct cygnus_pin_group *groups; 1148c2ecf20Sopenharmony_ci unsigned num_groups; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci const struct cygnus_pin_function *functions; 1178c2ecf20Sopenharmony_ci unsigned num_functions; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci struct cygnus_mux_log *mux_log; 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci spinlock_t lock; 1228c2ecf20Sopenharmony_ci}; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci/* 1258c2ecf20Sopenharmony_ci * Certain pins can be individually muxed to GPIO function 1268c2ecf20Sopenharmony_ci * 1278c2ecf20Sopenharmony_ci * @is_supported: flag to indicate GPIO mux is supported for this pin 1288c2ecf20Sopenharmony_ci * @offset: register offset for GPIO mux override of a pin 1298c2ecf20Sopenharmony_ci * @shift: bit shift for GPIO mux override of a pin 1308c2ecf20Sopenharmony_ci */ 1318c2ecf20Sopenharmony_cistruct cygnus_gpio_mux { 1328c2ecf20Sopenharmony_ci int is_supported; 1338c2ecf20Sopenharmony_ci unsigned int offset; 1348c2ecf20Sopenharmony_ci unsigned int shift; 1358c2ecf20Sopenharmony_ci}; 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci/* 1388c2ecf20Sopenharmony_ci * Description of a pin in Cygnus 1398c2ecf20Sopenharmony_ci * 1408c2ecf20Sopenharmony_ci * @pin: pin number 1418c2ecf20Sopenharmony_ci * @name: pin name 1428c2ecf20Sopenharmony_ci * @gpio_mux: GPIO override related information 1438c2ecf20Sopenharmony_ci */ 1448c2ecf20Sopenharmony_cistruct cygnus_pin { 1458c2ecf20Sopenharmony_ci unsigned pin; 1468c2ecf20Sopenharmony_ci char *name; 1478c2ecf20Sopenharmony_ci struct cygnus_gpio_mux gpio_mux; 1488c2ecf20Sopenharmony_ci}; 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci#define CYGNUS_PIN_DESC(p, n, i, o, s) \ 1518c2ecf20Sopenharmony_ci{ \ 1528c2ecf20Sopenharmony_ci .pin = p, \ 1538c2ecf20Sopenharmony_ci .name = n, \ 1548c2ecf20Sopenharmony_ci .gpio_mux = { \ 1558c2ecf20Sopenharmony_ci .is_supported = i, \ 1568c2ecf20Sopenharmony_ci .offset = o, \ 1578c2ecf20Sopenharmony_ci .shift = s, \ 1588c2ecf20Sopenharmony_ci }, \ 1598c2ecf20Sopenharmony_ci} 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci/* 1628c2ecf20Sopenharmony_ci * List of pins in Cygnus 1638c2ecf20Sopenharmony_ci */ 1648c2ecf20Sopenharmony_cistatic struct cygnus_pin cygnus_pins[] = { 1658c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(0, "ext_device_reset_n", 0, 0, 0), 1668c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(1, "chip_mode0", 0, 0, 0), 1678c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(2, "chip_mode1", 0, 0, 0), 1688c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(3, "chip_mode2", 0, 0, 0), 1698c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(4, "chip_mode3", 0, 0, 0), 1708c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(5, "chip_mode4", 0, 0, 0), 1718c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(6, "bsc0_scl", 0, 0, 0), 1728c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(7, "bsc0_sda", 0, 0, 0), 1738c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(8, "bsc1_scl", 0, 0, 0), 1748c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(9, "bsc1_sda", 0, 0, 0), 1758c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(10, "d1w_dq", 1, 0x28, 0), 1768c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(11, "d1wowstz_l", 1, 0x4, 28), 1778c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(12, "gpio0", 0, 0, 0), 1788c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(13, "gpio1", 0, 0, 0), 1798c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(14, "gpio2", 0, 0, 0), 1808c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(15, "gpio3", 0, 0, 0), 1818c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(16, "gpio4", 0, 0, 0), 1828c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(17, "gpio5", 0, 0, 0), 1838c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(18, "gpio6", 0, 0, 0), 1848c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(19, "gpio7", 0, 0, 0), 1858c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(20, "gpio8", 0, 0, 0), 1868c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(21, "gpio9", 0, 0, 0), 1878c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(22, "gpio10", 0, 0, 0), 1888c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(23, "gpio11", 0, 0, 0), 1898c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(24, "gpio12", 0, 0, 0), 1908c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(25, "gpio13", 0, 0, 0), 1918c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(26, "gpio14", 0, 0, 0), 1928c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(27, "gpio15", 0, 0, 0), 1938c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(28, "gpio16", 0, 0, 0), 1948c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(29, "gpio17", 0, 0, 0), 1958c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(30, "gpio18", 0, 0, 0), 1968c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(31, "gpio19", 0, 0, 0), 1978c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(32, "gpio20", 0, 0, 0), 1988c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(33, "gpio21", 0, 0, 0), 1998c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(34, "gpio22", 0, 0, 0), 2008c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(35, "gpio23", 0, 0, 0), 2018c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(36, "mdc", 0, 0, 0), 2028c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(37, "mdio", 0, 0, 0), 2038c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(38, "pwm0", 1, 0x10, 30), 2048c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(39, "pwm1", 1, 0x10, 28), 2058c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(40, "pwm2", 1, 0x10, 26), 2068c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(41, "pwm3", 1, 0x10, 24), 2078c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(42, "sc0_clk", 1, 0x10, 22), 2088c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(43, "sc0_cmdvcc_l", 1, 0x10, 20), 2098c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(44, "sc0_detect", 1, 0x10, 18), 2108c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(45, "sc0_fcb", 1, 0x10, 16), 2118c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(46, "sc0_io", 1, 0x10, 14), 2128c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(47, "sc0_rst_l", 1, 0x10, 12), 2138c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(48, "sc1_clk", 1, 0x10, 10), 2148c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(49, "sc1_cmdvcc_l", 1, 0x10, 8), 2158c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(50, "sc1_detect", 1, 0x10, 6), 2168c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(51, "sc1_fcb", 1, 0x10, 4), 2178c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(52, "sc1_io", 1, 0x10, 2), 2188c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(53, "sc1_rst_l", 1, 0x10, 0), 2198c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(54, "spi0_clk", 1, 0x18, 10), 2208c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(55, "spi0_mosi", 1, 0x18, 6), 2218c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(56, "spi0_miso", 1, 0x18, 8), 2228c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(57, "spi0_ss", 1, 0x18, 4), 2238c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(58, "spi1_clk", 1, 0x18, 2), 2248c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(59, "spi1_mosi", 1, 0x1c, 30), 2258c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(60, "spi1_miso", 1, 0x18, 0), 2268c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(61, "spi1_ss", 1, 0x1c, 28), 2278c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(62, "spi2_clk", 1, 0x1c, 26), 2288c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(63, "spi2_mosi", 1, 0x1c, 22), 2298c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(64, "spi2_miso", 1, 0x1c, 24), 2308c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(65, "spi2_ss", 1, 0x1c, 20), 2318c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(66, "spi3_clk", 1, 0x1c, 18), 2328c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(67, "spi3_mosi", 1, 0x1c, 14), 2338c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(68, "spi3_miso", 1, 0x1c, 16), 2348c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(69, "spi3_ss", 1, 0x1c, 12), 2358c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(70, "uart0_cts", 1, 0x1c, 10), 2368c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(71, "uart0_rts", 1, 0x1c, 8), 2378c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(72, "uart0_rx", 1, 0x1c, 6), 2388c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(73, "uart0_tx", 1, 0x1c, 4), 2398c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(74, "uart1_cts", 1, 0x1c, 2), 2408c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(75, "uart1_dcd", 1, 0x1c, 0), 2418c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(76, "uart1_dsr", 1, 0x20, 14), 2428c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(77, "uart1_dtr", 1, 0x20, 12), 2438c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(78, "uart1_ri", 1, 0x20, 10), 2448c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(79, "uart1_rts", 1, 0x20, 8), 2458c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(80, "uart1_rx", 1, 0x20, 6), 2468c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(81, "uart1_tx", 1, 0x20, 4), 2478c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(82, "uart3_rx", 1, 0x20, 2), 2488c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(83, "uart3_tx", 1, 0x20, 0), 2498c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(84, "sdio1_clk_sdcard", 1, 0x14, 6), 2508c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(85, "sdio1_cmd", 1, 0x14, 4), 2518c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(86, "sdio1_data0", 1, 0x14, 2), 2528c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(87, "sdio1_data1", 1, 0x14, 0), 2538c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(88, "sdio1_data2", 1, 0x18, 30), 2548c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(89, "sdio1_data3", 1, 0x18, 28), 2558c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(90, "sdio1_wp_n", 1, 0x18, 24), 2568c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(91, "sdio1_card_rst", 1, 0x14, 10), 2578c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(92, "sdio1_led_on", 1, 0x18, 26), 2588c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(93, "sdio1_cd", 1, 0x14, 8), 2598c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(94, "sdio0_clk_sdcard", 1, 0x14, 26), 2608c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(95, "sdio0_cmd", 1, 0x14, 24), 2618c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(96, "sdio0_data0", 1, 0x14, 22), 2628c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(97, "sdio0_data1", 1, 0x14, 20), 2638c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(98, "sdio0_data2", 1, 0x14, 18), 2648c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(99, "sdio0_data3", 1, 0x14, 16), 2658c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(100, "sdio0_wp_n", 1, 0x14, 12), 2668c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(101, "sdio0_card_rst", 1, 0x14, 30), 2678c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(102, "sdio0_led_on", 1, 0x14, 14), 2688c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(103, "sdio0_cd", 1, 0x14, 28), 2698c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(104, "sflash_clk", 1, 0x18, 22), 2708c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(105, "sflash_cs_l", 1, 0x18, 20), 2718c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(106, "sflash_mosi", 1, 0x18, 14), 2728c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(107, "sflash_miso", 1, 0x18, 16), 2738c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(108, "sflash_wp_n", 1, 0x18, 12), 2748c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(109, "sflash_hold_n", 1, 0x18, 18), 2758c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(110, "nand_ale", 1, 0xc, 30), 2768c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(111, "nand_ce0_l", 1, 0xc, 28), 2778c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(112, "nand_ce1_l", 1, 0xc, 26), 2788c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(113, "nand_cle", 1, 0xc, 24), 2798c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(114, "nand_dq0", 1, 0xc, 22), 2808c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(115, "nand_dq1", 1, 0xc, 20), 2818c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(116, "nand_dq2", 1, 0xc, 18), 2828c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(117, "nand_dq3", 1, 0xc, 16), 2838c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(118, "nand_dq4", 1, 0xc, 14), 2848c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(119, "nand_dq5", 1, 0xc, 12), 2858c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(120, "nand_dq6", 1, 0xc, 10), 2868c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(121, "nand_dq7", 1, 0xc, 8), 2878c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(122, "nand_rb_l", 1, 0xc, 6), 2888c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(123, "nand_re_l", 1, 0xc, 4), 2898c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(124, "nand_we_l", 1, 0xc, 2), 2908c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(125, "nand_wp_l", 1, 0xc, 0), 2918c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(126, "lcd_clac", 1, 0x4, 26), 2928c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(127, "lcd_clcp", 1, 0x4, 24), 2938c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(128, "lcd_cld0", 1, 0x4, 22), 2948c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(129, "lcd_cld1", 1, 0x4, 0), 2958c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(130, "lcd_cld10", 1, 0x4, 20), 2968c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(131, "lcd_cld11", 1, 0x4, 18), 2978c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(132, "lcd_cld12", 1, 0x4, 16), 2988c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(133, "lcd_cld13", 1, 0x4, 14), 2998c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(134, "lcd_cld14", 1, 0x4, 12), 3008c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(135, "lcd_cld15", 1, 0x4, 10), 3018c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(136, "lcd_cld16", 1, 0x4, 8), 3028c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(137, "lcd_cld17", 1, 0x4, 6), 3038c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(138, "lcd_cld18", 1, 0x4, 4), 3048c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(139, "lcd_cld19", 1, 0x4, 2), 3058c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(140, "lcd_cld2", 1, 0x8, 22), 3068c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(141, "lcd_cld20", 1, 0x8, 30), 3078c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(142, "lcd_cld21", 1, 0x8, 28), 3088c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(143, "lcd_cld22", 1, 0x8, 26), 3098c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(144, "lcd_cld23", 1, 0x8, 24), 3108c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(145, "lcd_cld3", 1, 0x8, 20), 3118c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(146, "lcd_cld4", 1, 0x8, 18), 3128c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(147, "lcd_cld5", 1, 0x8, 16), 3138c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(148, "lcd_cld6", 1, 0x8, 14), 3148c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(149, "lcd_cld7", 1, 0x8, 12), 3158c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(150, "lcd_cld8", 1, 0x8, 10), 3168c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(151, "lcd_cld9", 1, 0x8, 8), 3178c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(152, "lcd_clfp", 1, 0x8, 6), 3188c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(153, "lcd_clle", 1, 0x8, 4), 3198c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(154, "lcd_cllp", 1, 0x8, 2), 3208c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(155, "lcd_clpower", 1, 0x8, 0), 3218c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(156, "camera_vsync", 1, 0x4, 30), 3228c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(157, "camera_trigger", 1, 0x0, 0), 3238c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(158, "camera_strobe", 1, 0x0, 2), 3248c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(159, "camera_standby", 1, 0x0, 4), 3258c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(160, "camera_reset_n", 1, 0x0, 6), 3268c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(161, "camera_pixdata9", 1, 0x0, 8), 3278c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(162, "camera_pixdata8", 1, 0x0, 10), 3288c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(163, "camera_pixdata7", 1, 0x0, 12), 3298c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(164, "camera_pixdata6", 1, 0x0, 14), 3308c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(165, "camera_pixdata5", 1, 0x0, 16), 3318c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(166, "camera_pixdata4", 1, 0x0, 18), 3328c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(167, "camera_pixdata3", 1, 0x0, 20), 3338c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(168, "camera_pixdata2", 1, 0x0, 22), 3348c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(169, "camera_pixdata1", 1, 0x0, 24), 3358c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(170, "camera_pixdata0", 1, 0x0, 26), 3368c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(171, "camera_pixclk", 1, 0x0, 28), 3378c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(172, "camera_hsync", 1, 0x0, 30), 3388c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(173, "camera_pll_ref_clk", 0, 0, 0), 3398c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(174, "usb_id_indication", 0, 0, 0), 3408c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(175, "usb_vbus_indication", 0, 0, 0), 3418c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(176, "gpio0_3p3", 0, 0, 0), 3428c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(177, "gpio1_3p3", 0, 0, 0), 3438c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(178, "gpio2_3p3", 0, 0, 0), 3448c2ecf20Sopenharmony_ci CYGNUS_PIN_DESC(179, "gpio3_3p3", 0, 0, 0), 3458c2ecf20Sopenharmony_ci}; 3468c2ecf20Sopenharmony_ci 3478c2ecf20Sopenharmony_ci/* 3488c2ecf20Sopenharmony_ci * List of groups of pins 3498c2ecf20Sopenharmony_ci */ 3508c2ecf20Sopenharmony_cistatic const unsigned bsc1_pins[] = { 8, 9 }; 3518c2ecf20Sopenharmony_cistatic const unsigned pcie_clkreq_pins[] = { 8, 9 }; 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_cistatic const unsigned i2s2_0_pins[] = { 12 }; 3548c2ecf20Sopenharmony_cistatic const unsigned i2s2_1_pins[] = { 13 }; 3558c2ecf20Sopenharmony_cistatic const unsigned i2s2_2_pins[] = { 14 }; 3568c2ecf20Sopenharmony_cistatic const unsigned i2s2_3_pins[] = { 15 }; 3578c2ecf20Sopenharmony_cistatic const unsigned i2s2_4_pins[] = { 16 }; 3588c2ecf20Sopenharmony_ci 3598c2ecf20Sopenharmony_cistatic const unsigned pwm4_pins[] = { 17 }; 3608c2ecf20Sopenharmony_cistatic const unsigned pwm5_pins[] = { 18 }; 3618c2ecf20Sopenharmony_ci 3628c2ecf20Sopenharmony_cistatic const unsigned key0_pins[] = { 20 }; 3638c2ecf20Sopenharmony_cistatic const unsigned key1_pins[] = { 21 }; 3648c2ecf20Sopenharmony_cistatic const unsigned key2_pins[] = { 22 }; 3658c2ecf20Sopenharmony_cistatic const unsigned key3_pins[] = { 23 }; 3668c2ecf20Sopenharmony_cistatic const unsigned key4_pins[] = { 24 }; 3678c2ecf20Sopenharmony_cistatic const unsigned key5_pins[] = { 25 }; 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_cistatic const unsigned key6_pins[] = { 26 }; 3708c2ecf20Sopenharmony_cistatic const unsigned audio_dte0_pins[] = { 26 }; 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_cistatic const unsigned key7_pins[] = { 27 }; 3738c2ecf20Sopenharmony_cistatic const unsigned audio_dte1_pins[] = { 27 }; 3748c2ecf20Sopenharmony_ci 3758c2ecf20Sopenharmony_cistatic const unsigned key8_pins[] = { 28 }; 3768c2ecf20Sopenharmony_cistatic const unsigned key9_pins[] = { 29 }; 3778c2ecf20Sopenharmony_cistatic const unsigned key10_pins[] = { 30 }; 3788c2ecf20Sopenharmony_cistatic const unsigned key11_pins[] = { 31 }; 3798c2ecf20Sopenharmony_cistatic const unsigned key12_pins[] = { 32 }; 3808c2ecf20Sopenharmony_cistatic const unsigned key13_pins[] = { 33 }; 3818c2ecf20Sopenharmony_ci 3828c2ecf20Sopenharmony_cistatic const unsigned key14_pins[] = { 34 }; 3838c2ecf20Sopenharmony_cistatic const unsigned audio_dte2_pins[] = { 34 }; 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_cistatic const unsigned key15_pins[] = { 35 }; 3868c2ecf20Sopenharmony_cistatic const unsigned audio_dte3_pins[] = { 35 }; 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_cistatic const unsigned pwm0_pins[] = { 38 }; 3898c2ecf20Sopenharmony_cistatic const unsigned pwm1_pins[] = { 39 }; 3908c2ecf20Sopenharmony_cistatic const unsigned pwm2_pins[] = { 40 }; 3918c2ecf20Sopenharmony_cistatic const unsigned pwm3_pins[] = { 41 }; 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_cistatic const unsigned sdio0_pins[] = { 94, 95, 96, 97, 98, 99 }; 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_cistatic const unsigned smart_card0_pins[] = { 42, 43, 44, 46, 47 }; 3968c2ecf20Sopenharmony_cistatic const unsigned i2s0_0_pins[] = { 42, 43, 44, 46 }; 3978c2ecf20Sopenharmony_cistatic const unsigned spdif_pins[] = { 47 }; 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_cistatic const unsigned smart_card1_pins[] = { 48, 49, 50, 52, 53 }; 4008c2ecf20Sopenharmony_cistatic const unsigned i2s1_0_pins[] = { 48, 49, 50, 52 }; 4018c2ecf20Sopenharmony_ci 4028c2ecf20Sopenharmony_cistatic const unsigned spi0_pins[] = { 54, 55, 56, 57 }; 4038c2ecf20Sopenharmony_ci 4048c2ecf20Sopenharmony_cistatic const unsigned spi1_pins[] = { 58, 59, 60, 61 }; 4058c2ecf20Sopenharmony_ci 4068c2ecf20Sopenharmony_cistatic const unsigned spi2_pins[] = { 62, 63, 64, 65 }; 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_cistatic const unsigned spi3_pins[] = { 66, 67, 68, 69 }; 4098c2ecf20Sopenharmony_cistatic const unsigned sw_led0_0_pins[] = { 66, 67, 68, 69 }; 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_cistatic const unsigned d1w_pins[] = { 10, 11 }; 4128c2ecf20Sopenharmony_cistatic const unsigned uart4_pins[] = { 10, 11 }; 4138c2ecf20Sopenharmony_cistatic const unsigned sw_led2_0_pins[] = { 10, 11 }; 4148c2ecf20Sopenharmony_ci 4158c2ecf20Sopenharmony_cistatic const unsigned lcd_pins[] = { 126, 127, 128, 129, 130, 131, 132, 133, 4168c2ecf20Sopenharmony_ci 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 4178c2ecf20Sopenharmony_ci 148, 149, 150, 151, 152, 153, 154, 155 }; 4188c2ecf20Sopenharmony_cistatic const unsigned sram_0_pins[] = { 126, 127, 128, 129, 130, 131, 132, 133, 4198c2ecf20Sopenharmony_ci 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 4208c2ecf20Sopenharmony_ci 148, 149, 150, 151, 152, 153, 154, 155 }; 4218c2ecf20Sopenharmony_cistatic const unsigned spi5_pins[] = { 141, 142, 143, 144 }; 4228c2ecf20Sopenharmony_ci 4238c2ecf20Sopenharmony_cistatic const unsigned uart0_pins[] = { 70, 71, 72, 73 }; 4248c2ecf20Sopenharmony_cistatic const unsigned sw_led0_1_pins[] = { 70, 71, 72, 73 }; 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_cistatic const unsigned uart1_dte_pins[] = { 75, 76, 77, 78 }; 4278c2ecf20Sopenharmony_cistatic const unsigned uart2_pins[] = { 75, 76, 77, 78 }; 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_cistatic const unsigned uart1_pins[] = { 74, 79, 80, 81 }; 4308c2ecf20Sopenharmony_ci 4318c2ecf20Sopenharmony_cistatic const unsigned uart3_pins[] = { 82, 83 }; 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_cistatic const unsigned qspi_0_pins[] = { 104, 105, 106, 107 }; 4348c2ecf20Sopenharmony_ci 4358c2ecf20Sopenharmony_cistatic const unsigned nand_pins[] = { 110, 111, 112, 113, 114, 115, 116, 117, 4368c2ecf20Sopenharmony_ci 118, 119, 120, 121, 122, 123, 124, 125 }; 4378c2ecf20Sopenharmony_ci 4388c2ecf20Sopenharmony_cistatic const unsigned sdio0_cd_pins[] = { 103 }; 4398c2ecf20Sopenharmony_ci 4408c2ecf20Sopenharmony_cistatic const unsigned sdio0_mmc_pins[] = { 100, 101, 102 }; 4418c2ecf20Sopenharmony_ci 4428c2ecf20Sopenharmony_cistatic const unsigned sdio1_data_0_pins[] = { 86, 87 }; 4438c2ecf20Sopenharmony_cistatic const unsigned can0_pins[] = { 86, 87 }; 4448c2ecf20Sopenharmony_cistatic const unsigned spi4_0_pins[] = { 86, 87 }; 4458c2ecf20Sopenharmony_ci 4468c2ecf20Sopenharmony_cistatic const unsigned sdio1_data_1_pins[] = { 88, 89 }; 4478c2ecf20Sopenharmony_cistatic const unsigned can1_pins[] = { 88, 89 }; 4488c2ecf20Sopenharmony_cistatic const unsigned spi4_1_pins[] = { 88, 89 }; 4498c2ecf20Sopenharmony_ci 4508c2ecf20Sopenharmony_cistatic const unsigned sdio1_cd_pins[] = { 93 }; 4518c2ecf20Sopenharmony_ci 4528c2ecf20Sopenharmony_cistatic const unsigned sdio1_led_pins[] = { 84, 85 }; 4538c2ecf20Sopenharmony_cistatic const unsigned sw_led2_1_pins[] = { 84, 85 }; 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_cistatic const unsigned sdio1_mmc_pins[] = { 90, 91, 92 }; 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_cistatic const unsigned cam_led_pins[] = { 156, 157, 158, 159, 160 }; 4588c2ecf20Sopenharmony_cistatic const unsigned sw_led1_pins[] = { 156, 157, 158, 159 }; 4598c2ecf20Sopenharmony_ci 4608c2ecf20Sopenharmony_cistatic const unsigned cam_0_pins[] = { 169, 170, 171, 169, 170 }; 4618c2ecf20Sopenharmony_ci 4628c2ecf20Sopenharmony_cistatic const unsigned cam_1_pins[] = { 161, 162, 163, 164, 165, 166, 167, 4638c2ecf20Sopenharmony_ci 168 }; 4648c2ecf20Sopenharmony_cistatic const unsigned sram_1_pins[] = { 161, 162, 163, 164, 165, 166, 167, 4658c2ecf20Sopenharmony_ci 168 }; 4668c2ecf20Sopenharmony_ci 4678c2ecf20Sopenharmony_cistatic const unsigned qspi_1_pins[] = { 108, 109 }; 4688c2ecf20Sopenharmony_ci 4698c2ecf20Sopenharmony_cistatic const unsigned smart_card0_fcb_pins[] = { 45 }; 4708c2ecf20Sopenharmony_cistatic const unsigned i2s0_1_pins[] = { 45 }; 4718c2ecf20Sopenharmony_ci 4728c2ecf20Sopenharmony_cistatic const unsigned smart_card1_fcb_pins[] = { 51 }; 4738c2ecf20Sopenharmony_cistatic const unsigned i2s1_1_pins[] = { 51 }; 4748c2ecf20Sopenharmony_ci 4758c2ecf20Sopenharmony_cistatic const unsigned gpio0_3p3_pins[] = { 176 }; 4768c2ecf20Sopenharmony_cistatic const unsigned usb0_oc_pins[] = { 176 }; 4778c2ecf20Sopenharmony_ci 4788c2ecf20Sopenharmony_cistatic const unsigned gpio1_3p3_pins[] = { 177 }; 4798c2ecf20Sopenharmony_cistatic const unsigned usb1_oc_pins[] = { 177 }; 4808c2ecf20Sopenharmony_ci 4818c2ecf20Sopenharmony_cistatic const unsigned gpio2_3p3_pins[] = { 178 }; 4828c2ecf20Sopenharmony_cistatic const unsigned usb2_oc_pins[] = { 178 }; 4838c2ecf20Sopenharmony_ci 4848c2ecf20Sopenharmony_ci#define CYGNUS_PIN_GROUP(group_name, off, sh, al) \ 4858c2ecf20Sopenharmony_ci{ \ 4868c2ecf20Sopenharmony_ci .name = __stringify(group_name) "_grp", \ 4878c2ecf20Sopenharmony_ci .pins = group_name ## _pins, \ 4888c2ecf20Sopenharmony_ci .num_pins = ARRAY_SIZE(group_name ## _pins), \ 4898c2ecf20Sopenharmony_ci .mux = { \ 4908c2ecf20Sopenharmony_ci .offset = off, \ 4918c2ecf20Sopenharmony_ci .shift = sh, \ 4928c2ecf20Sopenharmony_ci .alt = al, \ 4938c2ecf20Sopenharmony_ci } \ 4948c2ecf20Sopenharmony_ci} 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_ci/* 4978c2ecf20Sopenharmony_ci * List of Cygnus pin groups 4988c2ecf20Sopenharmony_ci */ 4998c2ecf20Sopenharmony_cistatic const struct cygnus_pin_group cygnus_pin_groups[] = { 5008c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(i2s2_0, 0x0, 0, 2), 5018c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(i2s2_1, 0x0, 4, 2), 5028c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(i2s2_2, 0x0, 8, 2), 5038c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(i2s2_3, 0x0, 12, 2), 5048c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(i2s2_4, 0x0, 16, 2), 5058c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(pwm4, 0x0, 20, 0), 5068c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(pwm5, 0x0, 24, 2), 5078c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key0, 0x4, 0, 1), 5088c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key1, 0x4, 4, 1), 5098c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key2, 0x4, 8, 1), 5108c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key3, 0x4, 12, 1), 5118c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key4, 0x4, 16, 1), 5128c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key5, 0x4, 20, 1), 5138c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key6, 0x4, 24, 1), 5148c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(audio_dte0, 0x4, 24, 2), 5158c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key7, 0x4, 28, 1), 5168c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(audio_dte1, 0x4, 28, 2), 5178c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key8, 0x8, 0, 1), 5188c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key9, 0x8, 4, 1), 5198c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key10, 0x8, 8, 1), 5208c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key11, 0x8, 12, 1), 5218c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key12, 0x8, 16, 1), 5228c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key13, 0x8, 20, 1), 5238c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key14, 0x8, 24, 1), 5248c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(audio_dte2, 0x8, 24, 2), 5258c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(key15, 0x8, 28, 1), 5268c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(audio_dte3, 0x8, 28, 2), 5278c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(pwm0, 0xc, 0, 0), 5288c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(pwm1, 0xc, 4, 0), 5298c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(pwm2, 0xc, 8, 0), 5308c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(pwm3, 0xc, 12, 0), 5318c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(sdio0, 0xc, 16, 0), 5328c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(smart_card0, 0xc, 20, 0), 5338c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(i2s0_0, 0xc, 20, 1), 5348c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(spdif, 0xc, 20, 1), 5358c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(smart_card1, 0xc, 24, 0), 5368c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(i2s1_0, 0xc, 24, 1), 5378c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(spi0, 0x10, 0, 0), 5388c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(spi1, 0x10, 4, 0), 5398c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(spi2, 0x10, 8, 0), 5408c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(spi3, 0x10, 12, 0), 5418c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(sw_led0_0, 0x10, 12, 2), 5428c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(d1w, 0x10, 16, 0), 5438c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(uart4, 0x10, 16, 1), 5448c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(sw_led2_0, 0x10, 16, 2), 5458c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(lcd, 0x10, 20, 0), 5468c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(sram_0, 0x10, 20, 1), 5478c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(spi5, 0x10, 20, 2), 5488c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(uart0, 0x14, 0, 0), 5498c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(sw_led0_1, 0x14, 0, 2), 5508c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(uart1_dte, 0x14, 4, 0), 5518c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(uart2, 0x14, 4, 1), 5528c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(uart1, 0x14, 8, 0), 5538c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(uart3, 0x14, 12, 0), 5548c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(qspi_0, 0x14, 16, 0), 5558c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(nand, 0x14, 20, 0), 5568c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(sdio0_cd, 0x18, 0, 0), 5578c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(sdio0_mmc, 0x18, 4, 0), 5588c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(sdio1_data_0, 0x18, 8, 0), 5598c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(can0, 0x18, 8, 1), 5608c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(spi4_0, 0x18, 8, 2), 5618c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(sdio1_data_1, 0x18, 12, 0), 5628c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(can1, 0x18, 12, 1), 5638c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(spi4_1, 0x18, 12, 2), 5648c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(sdio1_cd, 0x18, 16, 0), 5658c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(sdio1_led, 0x18, 20, 0), 5668c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(sw_led2_1, 0x18, 20, 2), 5678c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(sdio1_mmc, 0x18, 24, 0), 5688c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(cam_led, 0x1c, 0, 0), 5698c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(sw_led1, 0x1c, 0, 1), 5708c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(cam_0, 0x1c, 4, 0), 5718c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(cam_1, 0x1c, 8, 0), 5728c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(sram_1, 0x1c, 8, 1), 5738c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(qspi_1, 0x1c, 12, 0), 5748c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(bsc1, 0x1c, 16, 0), 5758c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(pcie_clkreq, 0x1c, 16, 1), 5768c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(smart_card0_fcb, 0x20, 0, 0), 5778c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(i2s0_1, 0x20, 0, 1), 5788c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(smart_card1_fcb, 0x20, 4, 0), 5798c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(i2s1_1, 0x20, 4, 1), 5808c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(gpio0_3p3, 0x28, 0, 0), 5818c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(usb0_oc, 0x28, 0, 1), 5828c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(gpio1_3p3, 0x28, 4, 0), 5838c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(usb1_oc, 0x28, 4, 1), 5848c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(gpio2_3p3, 0x28, 8, 0), 5858c2ecf20Sopenharmony_ci CYGNUS_PIN_GROUP(usb2_oc, 0x28, 8, 1), 5868c2ecf20Sopenharmony_ci}; 5878c2ecf20Sopenharmony_ci 5888c2ecf20Sopenharmony_ci/* 5898c2ecf20Sopenharmony_ci * List of groups supported by functions 5908c2ecf20Sopenharmony_ci */ 5918c2ecf20Sopenharmony_cistatic const char * const i2s0_grps[] = { "i2s0_0_grp", "i2s0_1_grp" }; 5928c2ecf20Sopenharmony_cistatic const char * const i2s1_grps[] = { "i2s1_0_grp", "i2s1_1_grp" }; 5938c2ecf20Sopenharmony_cistatic const char * const i2s2_grps[] = { "i2s2_0_grp", "i2s2_1_grp", 5948c2ecf20Sopenharmony_ci "i2s2_2_grp", "i2s2_3_grp", "i2s2_4_grp" }; 5958c2ecf20Sopenharmony_cistatic const char * const spdif_grps[] = { "spdif_grp" }; 5968c2ecf20Sopenharmony_cistatic const char * const pwm0_grps[] = { "pwm0_grp" }; 5978c2ecf20Sopenharmony_cistatic const char * const pwm1_grps[] = { "pwm1_grp" }; 5988c2ecf20Sopenharmony_cistatic const char * const pwm2_grps[] = { "pwm2_grp" }; 5998c2ecf20Sopenharmony_cistatic const char * const pwm3_grps[] = { "pwm3_grp" }; 6008c2ecf20Sopenharmony_cistatic const char * const pwm4_grps[] = { "pwm4_grp" }; 6018c2ecf20Sopenharmony_cistatic const char * const pwm5_grps[] = { "pwm5_grp" }; 6028c2ecf20Sopenharmony_cistatic const char * const key_grps[] = { "key0_grp", "key1_grp", "key2_grp", 6038c2ecf20Sopenharmony_ci "key3_grp", "key4_grp", "key5_grp", "key6_grp", "key7_grp", "key8_grp", 6048c2ecf20Sopenharmony_ci "key9_grp", "key10_grp", "key11_grp", "key12_grp", "key13_grp", 6058c2ecf20Sopenharmony_ci "key14_grp", "key15_grp" }; 6068c2ecf20Sopenharmony_cistatic const char * const audio_dte_grps[] = { "audio_dte0_grp", 6078c2ecf20Sopenharmony_ci "audio_dte1_grp", "audio_dte2_grp", "audio_dte3_grp" }; 6088c2ecf20Sopenharmony_cistatic const char * const smart_card0_grps[] = { "smart_card0_grp", 6098c2ecf20Sopenharmony_ci "smart_card0_fcb_grp" }; 6108c2ecf20Sopenharmony_cistatic const char * const smart_card1_grps[] = { "smart_card1_grp", 6118c2ecf20Sopenharmony_ci "smart_card1_fcb_grp" }; 6128c2ecf20Sopenharmony_cistatic const char * const spi0_grps[] = { "spi0_grp" }; 6138c2ecf20Sopenharmony_cistatic const char * const spi1_grps[] = { "spi1_grp" }; 6148c2ecf20Sopenharmony_cistatic const char * const spi2_grps[] = { "spi2_grp" }; 6158c2ecf20Sopenharmony_cistatic const char * const spi3_grps[] = { "spi3_grp" }; 6168c2ecf20Sopenharmony_cistatic const char * const spi4_grps[] = { "spi4_0_grp", "spi4_1_grp" }; 6178c2ecf20Sopenharmony_cistatic const char * const spi5_grps[] = { "spi5_grp" }; 6188c2ecf20Sopenharmony_ci 6198c2ecf20Sopenharmony_cistatic const char * const sw_led0_grps[] = { "sw_led0_0_grp", 6208c2ecf20Sopenharmony_ci "sw_led0_1_grp" }; 6218c2ecf20Sopenharmony_cistatic const char * const sw_led1_grps[] = { "sw_led1_grp" }; 6228c2ecf20Sopenharmony_cistatic const char * const sw_led2_grps[] = { "sw_led2_0_grp", 6238c2ecf20Sopenharmony_ci "sw_led2_1_grp" }; 6248c2ecf20Sopenharmony_cistatic const char * const d1w_grps[] = { "d1w_grp" }; 6258c2ecf20Sopenharmony_cistatic const char * const lcd_grps[] = { "lcd_grp" }; 6268c2ecf20Sopenharmony_cistatic const char * const sram_grps[] = { "sram_0_grp", "sram_1_grp" }; 6278c2ecf20Sopenharmony_ci 6288c2ecf20Sopenharmony_cistatic const char * const uart0_grps[] = { "uart0_grp" }; 6298c2ecf20Sopenharmony_cistatic const char * const uart1_grps[] = { "uart1_grp", "uart1_dte_grp" }; 6308c2ecf20Sopenharmony_cistatic const char * const uart2_grps[] = { "uart2_grp" }; 6318c2ecf20Sopenharmony_cistatic const char * const uart3_grps[] = { "uart3_grp" }; 6328c2ecf20Sopenharmony_cistatic const char * const uart4_grps[] = { "uart4_grp" }; 6338c2ecf20Sopenharmony_cistatic const char * const qspi_grps[] = { "qspi_0_grp", "qspi_1_grp" }; 6348c2ecf20Sopenharmony_cistatic const char * const nand_grps[] = { "nand_grp" }; 6358c2ecf20Sopenharmony_cistatic const char * const sdio0_grps[] = { "sdio0_grp", "sdio0_cd_grp", 6368c2ecf20Sopenharmony_ci "sdio0_mmc_grp" }; 6378c2ecf20Sopenharmony_cistatic const char * const sdio1_grps[] = { "sdio1_data_0_grp", 6388c2ecf20Sopenharmony_ci "sdio1_data_1_grp", "sdio1_cd_grp", "sdio1_led_grp", "sdio1_mmc_grp" }; 6398c2ecf20Sopenharmony_cistatic const char * const can0_grps[] = { "can0_grp" }; 6408c2ecf20Sopenharmony_cistatic const char * const can1_grps[] = { "can1_grp" }; 6418c2ecf20Sopenharmony_cistatic const char * const cam_grps[] = { "cam_led_grp", "cam_0_grp", 6428c2ecf20Sopenharmony_ci "cam_1_grp" }; 6438c2ecf20Sopenharmony_cistatic const char * const bsc1_grps[] = { "bsc1_grp" }; 6448c2ecf20Sopenharmony_cistatic const char * const pcie_clkreq_grps[] = { "pcie_clkreq_grp" }; 6458c2ecf20Sopenharmony_cistatic const char * const usb0_oc_grps[] = { "usb0_oc_grp" }; 6468c2ecf20Sopenharmony_cistatic const char * const usb1_oc_grps[] = { "usb1_oc_grp" }; 6478c2ecf20Sopenharmony_cistatic const char * const usb2_oc_grps[] = { "usb2_oc_grp" }; 6488c2ecf20Sopenharmony_ci 6498c2ecf20Sopenharmony_ci#define CYGNUS_PIN_FUNCTION(func) \ 6508c2ecf20Sopenharmony_ci{ \ 6518c2ecf20Sopenharmony_ci .name = #func, \ 6528c2ecf20Sopenharmony_ci .groups = func ## _grps, \ 6538c2ecf20Sopenharmony_ci .num_groups = ARRAY_SIZE(func ## _grps), \ 6548c2ecf20Sopenharmony_ci} 6558c2ecf20Sopenharmony_ci 6568c2ecf20Sopenharmony_ci/* 6578c2ecf20Sopenharmony_ci * List of supported functions in Cygnus 6588c2ecf20Sopenharmony_ci */ 6598c2ecf20Sopenharmony_cistatic const struct cygnus_pin_function cygnus_pin_functions[] = { 6608c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(i2s0), 6618c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(i2s1), 6628c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(i2s2), 6638c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(spdif), 6648c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(pwm0), 6658c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(pwm1), 6668c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(pwm2), 6678c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(pwm3), 6688c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(pwm4), 6698c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(pwm5), 6708c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(key), 6718c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(audio_dte), 6728c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(smart_card0), 6738c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(smart_card1), 6748c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(spi0), 6758c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(spi1), 6768c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(spi2), 6778c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(spi3), 6788c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(spi4), 6798c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(spi5), 6808c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(sw_led0), 6818c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(sw_led1), 6828c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(sw_led2), 6838c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(d1w), 6848c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(lcd), 6858c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(sram), 6868c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(uart0), 6878c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(uart1), 6888c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(uart2), 6898c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(uart3), 6908c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(uart4), 6918c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(qspi), 6928c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(nand), 6938c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(sdio0), 6948c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(sdio1), 6958c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(can0), 6968c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(can1), 6978c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(cam), 6988c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(bsc1), 6998c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(pcie_clkreq), 7008c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(usb0_oc), 7018c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(usb1_oc), 7028c2ecf20Sopenharmony_ci CYGNUS_PIN_FUNCTION(usb2_oc), 7038c2ecf20Sopenharmony_ci}; 7048c2ecf20Sopenharmony_ci 7058c2ecf20Sopenharmony_cistatic int cygnus_get_groups_count(struct pinctrl_dev *pctrl_dev) 7068c2ecf20Sopenharmony_ci{ 7078c2ecf20Sopenharmony_ci struct cygnus_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 7088c2ecf20Sopenharmony_ci 7098c2ecf20Sopenharmony_ci return pinctrl->num_groups; 7108c2ecf20Sopenharmony_ci} 7118c2ecf20Sopenharmony_ci 7128c2ecf20Sopenharmony_cistatic const char *cygnus_get_group_name(struct pinctrl_dev *pctrl_dev, 7138c2ecf20Sopenharmony_ci unsigned selector) 7148c2ecf20Sopenharmony_ci{ 7158c2ecf20Sopenharmony_ci struct cygnus_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 7168c2ecf20Sopenharmony_ci 7178c2ecf20Sopenharmony_ci return pinctrl->groups[selector].name; 7188c2ecf20Sopenharmony_ci} 7198c2ecf20Sopenharmony_ci 7208c2ecf20Sopenharmony_cistatic int cygnus_get_group_pins(struct pinctrl_dev *pctrl_dev, 7218c2ecf20Sopenharmony_ci unsigned selector, const unsigned **pins, 7228c2ecf20Sopenharmony_ci unsigned *num_pins) 7238c2ecf20Sopenharmony_ci{ 7248c2ecf20Sopenharmony_ci struct cygnus_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 7258c2ecf20Sopenharmony_ci 7268c2ecf20Sopenharmony_ci *pins = pinctrl->groups[selector].pins; 7278c2ecf20Sopenharmony_ci *num_pins = pinctrl->groups[selector].num_pins; 7288c2ecf20Sopenharmony_ci 7298c2ecf20Sopenharmony_ci return 0; 7308c2ecf20Sopenharmony_ci} 7318c2ecf20Sopenharmony_ci 7328c2ecf20Sopenharmony_cistatic void cygnus_pin_dbg_show(struct pinctrl_dev *pctrl_dev, 7338c2ecf20Sopenharmony_ci struct seq_file *s, unsigned offset) 7348c2ecf20Sopenharmony_ci{ 7358c2ecf20Sopenharmony_ci seq_printf(s, " %s", dev_name(pctrl_dev->dev)); 7368c2ecf20Sopenharmony_ci} 7378c2ecf20Sopenharmony_ci 7388c2ecf20Sopenharmony_cistatic const struct pinctrl_ops cygnus_pinctrl_ops = { 7398c2ecf20Sopenharmony_ci .get_groups_count = cygnus_get_groups_count, 7408c2ecf20Sopenharmony_ci .get_group_name = cygnus_get_group_name, 7418c2ecf20Sopenharmony_ci .get_group_pins = cygnus_get_group_pins, 7428c2ecf20Sopenharmony_ci .pin_dbg_show = cygnus_pin_dbg_show, 7438c2ecf20Sopenharmony_ci .dt_node_to_map = pinconf_generic_dt_node_to_map_group, 7448c2ecf20Sopenharmony_ci .dt_free_map = pinctrl_utils_free_map, 7458c2ecf20Sopenharmony_ci}; 7468c2ecf20Sopenharmony_ci 7478c2ecf20Sopenharmony_cistatic int cygnus_get_functions_count(struct pinctrl_dev *pctrl_dev) 7488c2ecf20Sopenharmony_ci{ 7498c2ecf20Sopenharmony_ci struct cygnus_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 7508c2ecf20Sopenharmony_ci 7518c2ecf20Sopenharmony_ci return pinctrl->num_functions; 7528c2ecf20Sopenharmony_ci} 7538c2ecf20Sopenharmony_ci 7548c2ecf20Sopenharmony_cistatic const char *cygnus_get_function_name(struct pinctrl_dev *pctrl_dev, 7558c2ecf20Sopenharmony_ci unsigned selector) 7568c2ecf20Sopenharmony_ci{ 7578c2ecf20Sopenharmony_ci struct cygnus_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 7588c2ecf20Sopenharmony_ci 7598c2ecf20Sopenharmony_ci return pinctrl->functions[selector].name; 7608c2ecf20Sopenharmony_ci} 7618c2ecf20Sopenharmony_ci 7628c2ecf20Sopenharmony_cistatic int cygnus_get_function_groups(struct pinctrl_dev *pctrl_dev, 7638c2ecf20Sopenharmony_ci unsigned selector, 7648c2ecf20Sopenharmony_ci const char * const **groups, 7658c2ecf20Sopenharmony_ci unsigned * const num_groups) 7668c2ecf20Sopenharmony_ci{ 7678c2ecf20Sopenharmony_ci struct cygnus_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 7688c2ecf20Sopenharmony_ci 7698c2ecf20Sopenharmony_ci *groups = pinctrl->functions[selector].groups; 7708c2ecf20Sopenharmony_ci *num_groups = pinctrl->functions[selector].num_groups; 7718c2ecf20Sopenharmony_ci 7728c2ecf20Sopenharmony_ci return 0; 7738c2ecf20Sopenharmony_ci} 7748c2ecf20Sopenharmony_ci 7758c2ecf20Sopenharmony_cistatic int cygnus_pinmux_set(struct cygnus_pinctrl *pinctrl, 7768c2ecf20Sopenharmony_ci const struct cygnus_pin_function *func, 7778c2ecf20Sopenharmony_ci const struct cygnus_pin_group *grp, 7788c2ecf20Sopenharmony_ci struct cygnus_mux_log *mux_log) 7798c2ecf20Sopenharmony_ci{ 7808c2ecf20Sopenharmony_ci const struct cygnus_mux *mux = &grp->mux; 7818c2ecf20Sopenharmony_ci int i; 7828c2ecf20Sopenharmony_ci u32 val, mask = 0x7; 7838c2ecf20Sopenharmony_ci unsigned long flags; 7848c2ecf20Sopenharmony_ci 7858c2ecf20Sopenharmony_ci for (i = 0; i < CYGNUS_NUM_IOMUX; i++) { 7868c2ecf20Sopenharmony_ci if (mux->offset != mux_log[i].mux.offset || 7878c2ecf20Sopenharmony_ci mux->shift != mux_log[i].mux.shift) 7888c2ecf20Sopenharmony_ci continue; 7898c2ecf20Sopenharmony_ci 7908c2ecf20Sopenharmony_ci /* match found if we reach here */ 7918c2ecf20Sopenharmony_ci 7928c2ecf20Sopenharmony_ci /* if this is a new configuration, just do it! */ 7938c2ecf20Sopenharmony_ci if (!mux_log[i].is_configured) 7948c2ecf20Sopenharmony_ci break; 7958c2ecf20Sopenharmony_ci 7968c2ecf20Sopenharmony_ci /* 7978c2ecf20Sopenharmony_ci * IOMUX has been configured previously and one is trying to 7988c2ecf20Sopenharmony_ci * configure it to a different function 7998c2ecf20Sopenharmony_ci */ 8008c2ecf20Sopenharmony_ci if (mux_log[i].mux.alt != mux->alt) { 8018c2ecf20Sopenharmony_ci dev_err(pinctrl->dev, 8028c2ecf20Sopenharmony_ci "double configuration error detected!\n"); 8038c2ecf20Sopenharmony_ci dev_err(pinctrl->dev, "func:%s grp:%s\n", 8048c2ecf20Sopenharmony_ci func->name, grp->name); 8058c2ecf20Sopenharmony_ci return -EINVAL; 8068c2ecf20Sopenharmony_ci } else { 8078c2ecf20Sopenharmony_ci /* 8088c2ecf20Sopenharmony_ci * One tries to configure it to the same function. 8098c2ecf20Sopenharmony_ci * Just quit and don't bother 8108c2ecf20Sopenharmony_ci */ 8118c2ecf20Sopenharmony_ci return 0; 8128c2ecf20Sopenharmony_ci } 8138c2ecf20Sopenharmony_ci } 8148c2ecf20Sopenharmony_ci 8158c2ecf20Sopenharmony_ci mux_log[i].mux.alt = mux->alt; 8168c2ecf20Sopenharmony_ci mux_log[i].is_configured = true; 8178c2ecf20Sopenharmony_ci 8188c2ecf20Sopenharmony_ci spin_lock_irqsave(&pinctrl->lock, flags); 8198c2ecf20Sopenharmony_ci 8208c2ecf20Sopenharmony_ci val = readl(pinctrl->base0 + grp->mux.offset); 8218c2ecf20Sopenharmony_ci val &= ~(mask << grp->mux.shift); 8228c2ecf20Sopenharmony_ci val |= grp->mux.alt << grp->mux.shift; 8238c2ecf20Sopenharmony_ci writel(val, pinctrl->base0 + grp->mux.offset); 8248c2ecf20Sopenharmony_ci 8258c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&pinctrl->lock, flags); 8268c2ecf20Sopenharmony_ci 8278c2ecf20Sopenharmony_ci return 0; 8288c2ecf20Sopenharmony_ci} 8298c2ecf20Sopenharmony_ci 8308c2ecf20Sopenharmony_cistatic int cygnus_pinmux_set_mux(struct pinctrl_dev *pctrl_dev, 8318c2ecf20Sopenharmony_ci unsigned func_select, unsigned grp_select) 8328c2ecf20Sopenharmony_ci{ 8338c2ecf20Sopenharmony_ci struct cygnus_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 8348c2ecf20Sopenharmony_ci const struct cygnus_pin_function *func = 8358c2ecf20Sopenharmony_ci &pinctrl->functions[func_select]; 8368c2ecf20Sopenharmony_ci const struct cygnus_pin_group *grp = &pinctrl->groups[grp_select]; 8378c2ecf20Sopenharmony_ci 8388c2ecf20Sopenharmony_ci dev_dbg(pctrl_dev->dev, "func:%u name:%s grp:%u name:%s\n", 8398c2ecf20Sopenharmony_ci func_select, func->name, grp_select, grp->name); 8408c2ecf20Sopenharmony_ci 8418c2ecf20Sopenharmony_ci dev_dbg(pctrl_dev->dev, "offset:0x%08x shift:%u alt:%u\n", 8428c2ecf20Sopenharmony_ci grp->mux.offset, grp->mux.shift, grp->mux.alt); 8438c2ecf20Sopenharmony_ci 8448c2ecf20Sopenharmony_ci return cygnus_pinmux_set(pinctrl, func, grp, pinctrl->mux_log); 8458c2ecf20Sopenharmony_ci} 8468c2ecf20Sopenharmony_ci 8478c2ecf20Sopenharmony_cistatic int cygnus_gpio_request_enable(struct pinctrl_dev *pctrl_dev, 8488c2ecf20Sopenharmony_ci struct pinctrl_gpio_range *range, 8498c2ecf20Sopenharmony_ci unsigned pin) 8508c2ecf20Sopenharmony_ci{ 8518c2ecf20Sopenharmony_ci struct cygnus_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 8528c2ecf20Sopenharmony_ci const struct cygnus_gpio_mux *mux = pctrl_dev->desc->pins[pin].drv_data; 8538c2ecf20Sopenharmony_ci u32 val; 8548c2ecf20Sopenharmony_ci unsigned long flags; 8558c2ecf20Sopenharmony_ci 8568c2ecf20Sopenharmony_ci /* not all pins support GPIO pinmux override */ 8578c2ecf20Sopenharmony_ci if (!mux->is_supported) 8588c2ecf20Sopenharmony_ci return -ENOTSUPP; 8598c2ecf20Sopenharmony_ci 8608c2ecf20Sopenharmony_ci spin_lock_irqsave(&pinctrl->lock, flags); 8618c2ecf20Sopenharmony_ci 8628c2ecf20Sopenharmony_ci val = readl(pinctrl->base1 + mux->offset); 8638c2ecf20Sopenharmony_ci val |= 0x3 << mux->shift; 8648c2ecf20Sopenharmony_ci writel(val, pinctrl->base1 + mux->offset); 8658c2ecf20Sopenharmony_ci 8668c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&pinctrl->lock, flags); 8678c2ecf20Sopenharmony_ci 8688c2ecf20Sopenharmony_ci dev_dbg(pctrl_dev->dev, 8698c2ecf20Sopenharmony_ci "gpio request enable pin=%u offset=0x%x shift=%u\n", 8708c2ecf20Sopenharmony_ci pin, mux->offset, mux->shift); 8718c2ecf20Sopenharmony_ci 8728c2ecf20Sopenharmony_ci return 0; 8738c2ecf20Sopenharmony_ci} 8748c2ecf20Sopenharmony_ci 8758c2ecf20Sopenharmony_cistatic void cygnus_gpio_disable_free(struct pinctrl_dev *pctrl_dev, 8768c2ecf20Sopenharmony_ci struct pinctrl_gpio_range *range, 8778c2ecf20Sopenharmony_ci unsigned pin) 8788c2ecf20Sopenharmony_ci{ 8798c2ecf20Sopenharmony_ci struct cygnus_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev); 8808c2ecf20Sopenharmony_ci struct cygnus_gpio_mux *mux = pctrl_dev->desc->pins[pin].drv_data; 8818c2ecf20Sopenharmony_ci u32 val; 8828c2ecf20Sopenharmony_ci unsigned long flags; 8838c2ecf20Sopenharmony_ci 8848c2ecf20Sopenharmony_ci if (!mux->is_supported) 8858c2ecf20Sopenharmony_ci return; 8868c2ecf20Sopenharmony_ci 8878c2ecf20Sopenharmony_ci spin_lock_irqsave(&pinctrl->lock, flags); 8888c2ecf20Sopenharmony_ci 8898c2ecf20Sopenharmony_ci val = readl(pinctrl->base1 + mux->offset); 8908c2ecf20Sopenharmony_ci val &= ~(0x3 << mux->shift); 8918c2ecf20Sopenharmony_ci writel(val, pinctrl->base1 + mux->offset); 8928c2ecf20Sopenharmony_ci 8938c2ecf20Sopenharmony_ci spin_unlock_irqrestore(&pinctrl->lock, flags); 8948c2ecf20Sopenharmony_ci 8958c2ecf20Sopenharmony_ci dev_err(pctrl_dev->dev, 8968c2ecf20Sopenharmony_ci "gpio disable free pin=%u offset=0x%x shift=%u\n", 8978c2ecf20Sopenharmony_ci pin, mux->offset, mux->shift); 8988c2ecf20Sopenharmony_ci} 8998c2ecf20Sopenharmony_ci 9008c2ecf20Sopenharmony_cistatic const struct pinmux_ops cygnus_pinmux_ops = { 9018c2ecf20Sopenharmony_ci .get_functions_count = cygnus_get_functions_count, 9028c2ecf20Sopenharmony_ci .get_function_name = cygnus_get_function_name, 9038c2ecf20Sopenharmony_ci .get_function_groups = cygnus_get_function_groups, 9048c2ecf20Sopenharmony_ci .set_mux = cygnus_pinmux_set_mux, 9058c2ecf20Sopenharmony_ci .gpio_request_enable = cygnus_gpio_request_enable, 9068c2ecf20Sopenharmony_ci .gpio_disable_free = cygnus_gpio_disable_free, 9078c2ecf20Sopenharmony_ci}; 9088c2ecf20Sopenharmony_ci 9098c2ecf20Sopenharmony_cistatic struct pinctrl_desc cygnus_pinctrl_desc = { 9108c2ecf20Sopenharmony_ci .name = "cygnus-pinmux", 9118c2ecf20Sopenharmony_ci .pctlops = &cygnus_pinctrl_ops, 9128c2ecf20Sopenharmony_ci .pmxops = &cygnus_pinmux_ops, 9138c2ecf20Sopenharmony_ci}; 9148c2ecf20Sopenharmony_ci 9158c2ecf20Sopenharmony_cistatic int cygnus_mux_log_init(struct cygnus_pinctrl *pinctrl) 9168c2ecf20Sopenharmony_ci{ 9178c2ecf20Sopenharmony_ci struct cygnus_mux_log *log; 9188c2ecf20Sopenharmony_ci unsigned int i, j; 9198c2ecf20Sopenharmony_ci 9208c2ecf20Sopenharmony_ci pinctrl->mux_log = devm_kcalloc(pinctrl->dev, CYGNUS_NUM_IOMUX, 9218c2ecf20Sopenharmony_ci sizeof(struct cygnus_mux_log), 9228c2ecf20Sopenharmony_ci GFP_KERNEL); 9238c2ecf20Sopenharmony_ci if (!pinctrl->mux_log) 9248c2ecf20Sopenharmony_ci return -ENOMEM; 9258c2ecf20Sopenharmony_ci 9268c2ecf20Sopenharmony_ci for (i = 0; i < CYGNUS_NUM_IOMUX_REGS; i++) { 9278c2ecf20Sopenharmony_ci for (j = 0; j < CYGNUS_NUM_MUX_PER_REG; j++) { 9288c2ecf20Sopenharmony_ci log = &pinctrl->mux_log[i * CYGNUS_NUM_MUX_PER_REG 9298c2ecf20Sopenharmony_ci + j]; 9308c2ecf20Sopenharmony_ci log->mux.offset = i * 4; 9318c2ecf20Sopenharmony_ci log->mux.shift = j * 4; 9328c2ecf20Sopenharmony_ci log->mux.alt = 0; 9338c2ecf20Sopenharmony_ci log->is_configured = false; 9348c2ecf20Sopenharmony_ci } 9358c2ecf20Sopenharmony_ci } 9368c2ecf20Sopenharmony_ci 9378c2ecf20Sopenharmony_ci return 0; 9388c2ecf20Sopenharmony_ci} 9398c2ecf20Sopenharmony_ci 9408c2ecf20Sopenharmony_cistatic int cygnus_pinmux_probe(struct platform_device *pdev) 9418c2ecf20Sopenharmony_ci{ 9428c2ecf20Sopenharmony_ci struct cygnus_pinctrl *pinctrl; 9438c2ecf20Sopenharmony_ci int i, ret; 9448c2ecf20Sopenharmony_ci struct pinctrl_pin_desc *pins; 9458c2ecf20Sopenharmony_ci unsigned num_pins = ARRAY_SIZE(cygnus_pins); 9468c2ecf20Sopenharmony_ci 9478c2ecf20Sopenharmony_ci pinctrl = devm_kzalloc(&pdev->dev, sizeof(*pinctrl), GFP_KERNEL); 9488c2ecf20Sopenharmony_ci if (!pinctrl) 9498c2ecf20Sopenharmony_ci return -ENOMEM; 9508c2ecf20Sopenharmony_ci 9518c2ecf20Sopenharmony_ci pinctrl->dev = &pdev->dev; 9528c2ecf20Sopenharmony_ci platform_set_drvdata(pdev, pinctrl); 9538c2ecf20Sopenharmony_ci spin_lock_init(&pinctrl->lock); 9548c2ecf20Sopenharmony_ci 9558c2ecf20Sopenharmony_ci pinctrl->base0 = devm_platform_ioremap_resource(pdev, 0); 9568c2ecf20Sopenharmony_ci if (IS_ERR(pinctrl->base0)) { 9578c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "unable to map I/O space\n"); 9588c2ecf20Sopenharmony_ci return PTR_ERR(pinctrl->base0); 9598c2ecf20Sopenharmony_ci } 9608c2ecf20Sopenharmony_ci 9618c2ecf20Sopenharmony_ci pinctrl->base1 = devm_platform_ioremap_resource(pdev, 1); 9628c2ecf20Sopenharmony_ci if (IS_ERR(pinctrl->base1)) { 9638c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "unable to map I/O space\n"); 9648c2ecf20Sopenharmony_ci return PTR_ERR(pinctrl->base1); 9658c2ecf20Sopenharmony_ci } 9668c2ecf20Sopenharmony_ci 9678c2ecf20Sopenharmony_ci ret = cygnus_mux_log_init(pinctrl); 9688c2ecf20Sopenharmony_ci if (ret) { 9698c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "unable to initialize IOMUX log\n"); 9708c2ecf20Sopenharmony_ci return ret; 9718c2ecf20Sopenharmony_ci } 9728c2ecf20Sopenharmony_ci 9738c2ecf20Sopenharmony_ci pins = devm_kcalloc(&pdev->dev, num_pins, sizeof(*pins), GFP_KERNEL); 9748c2ecf20Sopenharmony_ci if (!pins) 9758c2ecf20Sopenharmony_ci return -ENOMEM; 9768c2ecf20Sopenharmony_ci 9778c2ecf20Sopenharmony_ci for (i = 0; i < num_pins; i++) { 9788c2ecf20Sopenharmony_ci pins[i].number = cygnus_pins[i].pin; 9798c2ecf20Sopenharmony_ci pins[i].name = cygnus_pins[i].name; 9808c2ecf20Sopenharmony_ci pins[i].drv_data = &cygnus_pins[i].gpio_mux; 9818c2ecf20Sopenharmony_ci } 9828c2ecf20Sopenharmony_ci 9838c2ecf20Sopenharmony_ci pinctrl->groups = cygnus_pin_groups; 9848c2ecf20Sopenharmony_ci pinctrl->num_groups = ARRAY_SIZE(cygnus_pin_groups); 9858c2ecf20Sopenharmony_ci pinctrl->functions = cygnus_pin_functions; 9868c2ecf20Sopenharmony_ci pinctrl->num_functions = ARRAY_SIZE(cygnus_pin_functions); 9878c2ecf20Sopenharmony_ci cygnus_pinctrl_desc.pins = pins; 9888c2ecf20Sopenharmony_ci cygnus_pinctrl_desc.npins = num_pins; 9898c2ecf20Sopenharmony_ci 9908c2ecf20Sopenharmony_ci pinctrl->pctl = devm_pinctrl_register(&pdev->dev, &cygnus_pinctrl_desc, 9918c2ecf20Sopenharmony_ci pinctrl); 9928c2ecf20Sopenharmony_ci if (IS_ERR(pinctrl->pctl)) { 9938c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "unable to register Cygnus IOMUX pinctrl\n"); 9948c2ecf20Sopenharmony_ci return PTR_ERR(pinctrl->pctl); 9958c2ecf20Sopenharmony_ci } 9968c2ecf20Sopenharmony_ci 9978c2ecf20Sopenharmony_ci return 0; 9988c2ecf20Sopenharmony_ci} 9998c2ecf20Sopenharmony_ci 10008c2ecf20Sopenharmony_cistatic const struct of_device_id cygnus_pinmux_of_match[] = { 10018c2ecf20Sopenharmony_ci { .compatible = "brcm,cygnus-pinmux" }, 10028c2ecf20Sopenharmony_ci { } 10038c2ecf20Sopenharmony_ci}; 10048c2ecf20Sopenharmony_ci 10058c2ecf20Sopenharmony_cistatic struct platform_driver cygnus_pinmux_driver = { 10068c2ecf20Sopenharmony_ci .driver = { 10078c2ecf20Sopenharmony_ci .name = "cygnus-pinmux", 10088c2ecf20Sopenharmony_ci .of_match_table = cygnus_pinmux_of_match, 10098c2ecf20Sopenharmony_ci .suppress_bind_attrs = true, 10108c2ecf20Sopenharmony_ci }, 10118c2ecf20Sopenharmony_ci .probe = cygnus_pinmux_probe, 10128c2ecf20Sopenharmony_ci}; 10138c2ecf20Sopenharmony_ci 10148c2ecf20Sopenharmony_cistatic int __init cygnus_pinmux_init(void) 10158c2ecf20Sopenharmony_ci{ 10168c2ecf20Sopenharmony_ci return platform_driver_register(&cygnus_pinmux_driver); 10178c2ecf20Sopenharmony_ci} 10188c2ecf20Sopenharmony_ciarch_initcall(cygnus_pinmux_init); 1019