Lines Matching +full:scu +full:- +full:clk
2 * Pinctrl driver for NXP LPC18xx/LPC43xx System Control Unit (SCU)
12 #include <linux/clk.h>
18 #include <linux/pinctrl/pinconf-generic.h>
24 #include "pinctrl-utils.h"
26 /* LPC18XX SCU analog function registers */
32 /* LPC18XX SCU pin register definitions */
54 /* LPC18XX SCU pin interrupt select registers */
68 TYPE_ND, /* Normal-drive */
69 TYPE_HD, /* High-drive */
70 TYPE_HS, /* High-speed */
191 struct clk *clk; member
639 {"nxp,gpio-pin-interrupt", PIN_CONFIG_GPIO_PIN_INT, 0},
660 return -EINVAL; in lpc18xx_pconf_get_usb1()
667 return -EINVAL; in lpc18xx_pconf_get_usb1()
671 return -ENOTSUPP; in lpc18xx_pconf_get_usb1()
692 return -EINVAL; in lpc18xx_pconf_get_i2c0()
711 return -EINVAL; in lpc18xx_pconf_get_i2c0()
717 return -ENOTSUPP; in lpc18xx_pconf_get_i2c0()
729 return -EINVAL; in lpc18xx_pin_to_gpio()
731 return pin - range->pin_base + range->base; in lpc18xx_pin_to_gpio()
748 return -EINVAL; in lpc18xx_get_pintsel()
764 struct lpc18xx_scu_data *scu = pinctrl_dev_get_drvdata(pctldev); in lpc18xx_pconf_get_gpio_pin_int() local
770 return -ENOTSUPP; in lpc18xx_pconf_get_gpio_pin_int()
776 * PINTSEL registers. *arg indicates which interrupt number (0-7). in lpc18xx_pconf_get_gpio_pin_int()
779 ret = lpc18xx_get_pintsel(scu->base + LPC18XX_SCU_PINTSEL0, val, arg); in lpc18xx_pconf_get_gpio_pin_int()
783 return lpc18xx_get_pintsel(scu->base + LPC18XX_SCU_PINTSEL1, val, arg); in lpc18xx_pconf_get_gpio_pin_int()
795 return -EINVAL; in lpc18xx_pconf_get_pin()
800 return -EINVAL; in lpc18xx_pconf_get_pin()
809 return -EINVAL; in lpc18xx_pconf_get_pin()
816 return -EINVAL; in lpc18xx_pconf_get_pin()
820 if (pin_cap->type == TYPE_HD) in lpc18xx_pconf_get_pin()
821 return -ENOTSUPP; in lpc18xx_pconf_get_pin()
831 return -EINVAL; in lpc18xx_pconf_get_pin()
837 if (pin_cap->type != TYPE_HD) in lpc18xx_pconf_get_pin()
838 return -ENOTSUPP; in lpc18xx_pconf_get_pin()
856 return -ENOTSUPP; in lpc18xx_pconf_get_pin()
877 struct lpc18xx_scu_data *scu = pinctrl_dev_get_drvdata(pctldev); in lpc18xx_pconf_get() local
885 return -EINVAL; in lpc18xx_pconf_get()
887 reg = readl(scu->base + pin_cap->offset); in lpc18xx_pconf_get()
889 if (pin_cap->type == TYPE_I2C0) in lpc18xx_pconf_get()
891 else if (pin_cap->type == TYPE_USB1) in lpc18xx_pconf_get()
925 dev_err(pctldev->dev, "Property not supported\n"); in lpc18xx_pconf_set_usb1()
926 return -ENOTSUPP; in lpc18xx_pconf_set_usb1()
965 return -ENOTSUPP; in lpc18xx_pconf_set_i2c0()
976 dev_err(pctldev->dev, "Property not supported\n"); in lpc18xx_pconf_set_i2c0()
977 return -ENOTSUPP; in lpc18xx_pconf_set_i2c0()
986 struct lpc18xx_scu_data *scu = pinctrl_dev_get_drvdata(pctldev); in lpc18xx_pconf_set_gpio_pin_int() local
991 return -EINVAL; in lpc18xx_pconf_set_gpio_pin_int()
995 return -ENOTSUPP; in lpc18xx_pconf_set_gpio_pin_int()
1001 reg_val = readl(scu->base + reg_offset); in lpc18xx_pconf_set_gpio_pin_int()
1004 writel(reg_val, scu->base + reg_offset); in lpc18xx_pconf_set_gpio_pin_int()
1035 if (pin_cap->type == TYPE_HD) { in lpc18xx_pconf_set_pin()
1036 dev_err(pctldev->dev, "Slew rate unsupported on high-drive pins\n"); in lpc18xx_pconf_set_pin()
1037 return -ENOTSUPP; in lpc18xx_pconf_set_pin()
1054 if (pin_cap->type != TYPE_HD) { in lpc18xx_pconf_set_pin()
1055 dev_err(pctldev->dev, "Drive strength available only on high-drive pins\n"); in lpc18xx_pconf_set_pin()
1056 return -ENOTSUPP; in lpc18xx_pconf_set_pin()
1061 case 20: param_val -= 5; in lpc18xx_pconf_set_pin()
1063 case 14: param_val -= 5; in lpc18xx_pconf_set_pin()
1065 case 8: param_val -= 3; in lpc18xx_pconf_set_pin()
1067 case 4: param_val -= 4; in lpc18xx_pconf_set_pin()
1070 dev_err(pctldev->dev, "Drive strength %u unsupported\n", param_val); in lpc18xx_pconf_set_pin()
1071 return -ENOTSUPP; in lpc18xx_pconf_set_pin()
1080 dev_err(pctldev->dev, "Property not supported\n"); in lpc18xx_pconf_set_pin()
1081 return -ENOTSUPP; in lpc18xx_pconf_set_pin()
1090 struct lpc18xx_scu_data *scu = pinctrl_dev_get_drvdata(pctldev); in lpc18xx_pconf_set() local
1100 return -EINVAL; in lpc18xx_pconf_set()
1102 reg = readl(scu->base + pin_cap->offset); in lpc18xx_pconf_set()
1108 if (pin_cap->type == TYPE_I2C0) in lpc18xx_pconf_set()
1110 else if (pin_cap->type == TYPE_USB1) in lpc18xx_pconf_set()
1119 writel(reg, scu->base + pin_cap->offset); in lpc18xx_pconf_set()
1146 struct lpc18xx_scu_data *scu = pinctrl_dev_get_drvdata(pctldev); in lpc18xx_pmx_get_func_groups() local
1148 *groups = scu->func[function].groups; in lpc18xx_pmx_get_func_groups()
1149 *num_groups = scu->func[function].ngroups; in lpc18xx_pmx_get_func_groups()
1157 struct lpc18xx_scu_data *scu = pinctrl_dev_get_drvdata(pctldev); in lpc18xx_pmx_set() local
1163 if (pin->type == TYPE_USB1) { in lpc18xx_pmx_set()
1170 if (pin->type == TYPE_I2C0) { in lpc18xx_pmx_set()
1177 if (function == FUNC_ADC && (pin->analog & LPC18XX_ANALOG_PIN)) { in lpc18xx_pmx_set()
1180 writel(LPC18XX_SCU_ANALOG_PIN_CFG, scu->base + pin->offset); in lpc18xx_pmx_set()
1182 if (LPC18XX_ANALOG_ADC(pin->analog) == 0) in lpc18xx_pmx_set()
1187 reg = readl(scu->base + offset); in lpc18xx_pmx_set()
1188 reg |= pin->analog & LPC18XX_ANALOG_BIT_MASK; in lpc18xx_pmx_set()
1189 writel(reg, scu->base + offset); in lpc18xx_pmx_set()
1194 if (function == FUNC_DAC && (pin->analog & LPC18XX_ANALOG_PIN)) { in lpc18xx_pmx_set()
1195 writel(LPC18XX_SCU_ANALOG_PIN_CFG, scu->base + pin->offset); in lpc18xx_pmx_set()
1197 reg = readl(scu->base + LPC18XX_SCU_REG_ENAIO2); in lpc18xx_pmx_set()
1199 writel(reg, scu->base + LPC18XX_SCU_REG_ENAIO2); in lpc18xx_pmx_set()
1205 if (function == pin->functions[func]) in lpc18xx_pmx_set()
1212 reg = readl(scu->base + pin->offset); in lpc18xx_pmx_set()
1214 writel(reg | func, scu->base + pin->offset); in lpc18xx_pmx_set()
1218 dev_err(pctldev->dev, "Pin %s can't be %s\n", lpc18xx_pins[group].name, in lpc18xx_pmx_set()
1220 return -EINVAL; in lpc18xx_pmx_set()
1261 .name = "lpc18xx/43xx-scu",
1280 if (function == FUNC_DAC && p->analog == DAC) in lpc18xx_valid_pin_function()
1283 if (function == FUNC_ADC && p->analog) in lpc18xx_valid_pin_function()
1286 if (function == FUNC_I2C0 && p->type == TYPE_I2C0) in lpc18xx_valid_pin_function()
1289 if (function == FUNC_USB1 && p->type == TYPE_USB1) in lpc18xx_valid_pin_function()
1293 if (function == p->functions[i]) in lpc18xx_valid_pin_function()
1301 struct lpc18xx_scu_data *scu) in lpc18xx_create_group_func_map() argument
1312 scu->func[func].ngroups = ngroups; in lpc18xx_create_group_func_map()
1313 scu->func[func].groups = devm_kcalloc(dev, in lpc18xx_create_group_func_map()
1316 if (!scu->func[func].groups) in lpc18xx_create_group_func_map()
1317 return -ENOMEM; in lpc18xx_create_group_func_map()
1320 scu->func[func].groups[i] = lpc18xx_pins[pins[i]].name; in lpc18xx_create_group_func_map()
1328 struct lpc18xx_scu_data *scu; in lpc18xx_scu_probe() local
1331 scu = devm_kzalloc(&pdev->dev, sizeof(*scu), GFP_KERNEL); in lpc18xx_scu_probe()
1332 if (!scu) in lpc18xx_scu_probe()
1333 return -ENOMEM; in lpc18xx_scu_probe()
1335 scu->base = devm_platform_ioremap_resource(pdev, 0); in lpc18xx_scu_probe()
1336 if (IS_ERR(scu->base)) in lpc18xx_scu_probe()
1337 return PTR_ERR(scu->base); in lpc18xx_scu_probe()
1339 scu->clk = devm_clk_get(&pdev->dev, NULL); in lpc18xx_scu_probe()
1340 if (IS_ERR(scu->clk)) { in lpc18xx_scu_probe()
1341 dev_err(&pdev->dev, "Input clock not found.\n"); in lpc18xx_scu_probe()
1342 return PTR_ERR(scu->clk); in lpc18xx_scu_probe()
1345 ret = lpc18xx_create_group_func_map(&pdev->dev, scu); in lpc18xx_scu_probe()
1347 dev_err(&pdev->dev, "Unable to create group func map.\n"); in lpc18xx_scu_probe()
1351 ret = clk_prepare_enable(scu->clk); in lpc18xx_scu_probe()
1353 dev_err(&pdev->dev, "Unable to enable clock.\n"); in lpc18xx_scu_probe()
1357 platform_set_drvdata(pdev, scu); in lpc18xx_scu_probe()
1359 scu->pctl = devm_pinctrl_register(&pdev->dev, &lpc18xx_scu_desc, scu); in lpc18xx_scu_probe()
1360 if (IS_ERR(scu->pctl)) { in lpc18xx_scu_probe()
1361 dev_err(&pdev->dev, "Could not register pinctrl driver\n"); in lpc18xx_scu_probe()
1362 clk_disable_unprepare(scu->clk); in lpc18xx_scu_probe()
1363 return PTR_ERR(scu->pctl); in lpc18xx_scu_probe()
1370 { .compatible = "nxp,lpc1850-scu" },
1377 .name = "lpc18xx-scu",