Lines Matching +full:gpio +full:- +full:defaults
12 #include <asm-generic/gpio.h>
32 u8 reg_shift = oft * hcg->bit_per_gpio + hcg->shift; in hsdk_creg_gpio_set_value()
33 u32 reg = readl(hcg->regs); in hsdk_creg_gpio_set_value()
35 reg &= ~(GENMASK(hcg->bit_per_gpio - 1, 0) << reg_shift); in hsdk_creg_gpio_set_value()
36 reg |= ((val ? hcg->deactivate : hcg->activate) << reg_shift); in hsdk_creg_gpio_set_value()
38 writel(reg, hcg->regs); in hsdk_creg_gpio_set_value()
55 pr_err("%s can't be used as input!\n", uc_priv->bank_name); in hsdk_creg_gpio_direction_input()
57 return -ENOTSUPP; in hsdk_creg_gpio_direction_input()
63 u32 val = readl(hcg->regs); in hsdk_creg_gpio_get_value()
65 val >>= oft * hcg->bit_per_gpio + hcg->shift; in hsdk_creg_gpio_get_value()
66 val &= GENMASK(hcg->bit_per_gpio - 1, 0); in hsdk_creg_gpio_get_value()
67 return (val == hcg->deactivate) ? 1 : 0; in hsdk_creg_gpio_get_value()
82 const u8 *defaults; in hsdk_creg_gpio_probe() local
84 hcg->regs = (u32 *)devfdt_get_addr_ptr(dev); in hsdk_creg_gpio_probe()
85 gpio_count = dev_read_u32_default(dev, "gpio-count", 1); in hsdk_creg_gpio_probe()
86 shift = dev_read_u32_default(dev, "gpio-first-shift", 0); in hsdk_creg_gpio_probe()
87 bit_per_gpio = dev_read_u32_default(dev, "gpio-bit-per-line", 1); in hsdk_creg_gpio_probe()
88 activate = dev_read_u32_default(dev, "gpio-activate-val", 1); in hsdk_creg_gpio_probe()
89 deactivate = dev_read_u32_default(dev, "gpio-deactivate-val", 0); in hsdk_creg_gpio_probe()
90 defaults = dev_read_u8_array_ptr(dev, "gpio-default-val", gpio_count); in hsdk_creg_gpio_probe()
92 uc_priv->bank_name = dev_read_string(dev, "gpio-bank-name"); in hsdk_creg_gpio_probe()
93 if (!uc_priv->bank_name) in hsdk_creg_gpio_probe()
94 uc_priv->bank_name = dev_read_name(dev); in hsdk_creg_gpio_probe()
97 pr_err("%s: 'gpio-bit-per-line' can't be 0\n", in hsdk_creg_gpio_probe()
98 uc_priv->bank_name); in hsdk_creg_gpio_probe()
100 return -EINVAL; in hsdk_creg_gpio_probe()
104 pr_err("%s: 'gpio-count' can't be 0\n", in hsdk_creg_gpio_probe()
105 uc_priv->bank_name); in hsdk_creg_gpio_probe()
107 return -EINVAL; in hsdk_creg_gpio_probe()
112 uc_priv->bank_name, gpio_count * bit_per_gpio + shift); in hsdk_creg_gpio_probe()
114 return -EINVAL; in hsdk_creg_gpio_probe()
118 pr_err("%s: 'gpio-activate-val' can't be more than %lu\n", in hsdk_creg_gpio_probe()
119 uc_priv->bank_name, GENMASK(bit_per_gpio - 1, 0)); in hsdk_creg_gpio_probe()
121 return -EINVAL; in hsdk_creg_gpio_probe()
125 pr_err("%s: 'gpio-deactivate-val' can't be more than %lu\n", in hsdk_creg_gpio_probe()
126 uc_priv->bank_name, GENMASK(bit_per_gpio - 1, 0)); in hsdk_creg_gpio_probe()
128 return -EINVAL; in hsdk_creg_gpio_probe()
132 pr_err("%s: 'gpio-deactivate-val' and 'gpio-activate-val' can't be equal\n", in hsdk_creg_gpio_probe()
133 uc_priv->bank_name); in hsdk_creg_gpio_probe()
135 return -EINVAL; in hsdk_creg_gpio_probe()
138 hcg->shift = (u8)shift; in hsdk_creg_gpio_probe()
139 hcg->bit_per_gpio = (u8)bit_per_gpio; in hsdk_creg_gpio_probe()
140 hcg->activate = (u8)activate; in hsdk_creg_gpio_probe()
141 hcg->deactivate = (u8)deactivate; in hsdk_creg_gpio_probe()
142 uc_priv->gpio_count = gpio_count; in hsdk_creg_gpio_probe()
144 /* Setup default GPIO value if we have "gpio-default-val" array */ in hsdk_creg_gpio_probe()
145 if (defaults) in hsdk_creg_gpio_probe()
147 hsdk_creg_gpio_set_value(dev, i, defaults[i]); in hsdk_creg_gpio_probe()
149 pr_debug("%s GPIO [0x%p] controller with %d gpios probed\n", in hsdk_creg_gpio_probe()
150 uc_priv->bank_name, hcg->regs, uc_priv->gpio_count); in hsdk_creg_gpio_probe()
156 { .compatible = "snps,creg-gpio" },