Lines Matching refs:p
48 struct ralink_priv *p = pinctrl_dev_get_drvdata(pctrldev); in ralink_get_group_count() local
50 return p->group_count; in ralink_get_group_count()
56 struct ralink_priv *p = pinctrl_dev_get_drvdata(pctrldev); in ralink_get_group_name() local
58 return (group >= p->group_count) ? NULL : p->group_names[group]; in ralink_get_group_name()
66 struct ralink_priv *p = pinctrl_dev_get_drvdata(pctrldev); in ralink_get_group_pins() local
68 if (group >= p->group_count) in ralink_get_group_pins()
71 *pins = p->groups[group].func[0].pins; in ralink_get_group_pins()
72 *num_pins = p->groups[group].func[0].pin_count; in ralink_get_group_pins()
87 struct ralink_priv *p = pinctrl_dev_get_drvdata(pctrldev); in ralink_pmx_func_count() local
89 return p->func_count; in ralink_pmx_func_count()
95 struct ralink_priv *p = pinctrl_dev_get_drvdata(pctrldev); in ralink_pmx_func_name() local
97 return p->func[func]->name; in ralink_pmx_func_name()
105 struct ralink_priv *p = pinctrl_dev_get_drvdata(pctrldev); in ralink_pmx_group_get_groups() local
107 if (p->func[func]->group_count == 1) in ralink_pmx_group_get_groups()
108 *groups = &p->group_names[p->func[func]->groups[0]]; in ralink_pmx_group_get_groups()
110 *groups = p->group_names; in ralink_pmx_group_get_groups()
112 *num_groups = p->func[func]->group_count; in ralink_pmx_group_get_groups()
120 struct ralink_priv *p = pinctrl_dev_get_drvdata(pctrldev); in ralink_pmx_group_enable() local
127 if (p->groups[group].enabled) { in ralink_pmx_group_enable()
128 dev_err(p->dev, "%s is already enabled\n", in ralink_pmx_group_enable()
129 p->groups[group].name); in ralink_pmx_group_enable()
133 p->groups[group].enabled = 1; in ralink_pmx_group_enable()
134 p->func[func]->enabled = 1; in ralink_pmx_group_enable()
136 shift = p->groups[group].shift; in ralink_pmx_group_enable()
142 mode &= ~(p->groups[group].mask << shift); in ralink_pmx_group_enable()
145 for (i = 0; i < p->groups[group].func[0].pin_count; i++) in ralink_pmx_group_enable()
146 p->gpio[p->groups[group].func[0].pins[i]] = 1; in ralink_pmx_group_enable()
150 mode |= p->groups[group].gpio << shift; in ralink_pmx_group_enable()
152 for (i = 0; i < p->func[func]->pin_count; i++) in ralink_pmx_group_enable()
153 p->gpio[p->func[func]->pins[i]] = 0; in ralink_pmx_group_enable()
154 mode |= p->func[func]->value << shift; in ralink_pmx_group_enable()
165 struct ralink_priv *p = pinctrl_dev_get_drvdata(pctrldev); in ralink_pmx_group_gpio_request_enable() local
167 if (!p->gpio[pin]) { in ralink_pmx_group_gpio_request_enable()
168 dev_err(p->dev, "pin %d is not set to gpio mux\n", pin); in ralink_pmx_group_gpio_request_enable()
194 static int ralink_pinctrl_index(struct ralink_priv *p) in ralink_pinctrl_index() argument
196 struct ralink_pmx_group *mux = p->groups; in ralink_pinctrl_index()
201 p->group_count++; in ralink_pinctrl_index()
206 p->group_names = devm_kcalloc(p->dev, p->group_count, in ralink_pinctrl_index()
208 if (!p->group_names) in ralink_pinctrl_index()
211 for (i = 0; i < p->group_count; i++) { in ralink_pinctrl_index()
212 p->group_names[i] = p->groups[i].name; in ralink_pinctrl_index()
213 p->func_count += p->groups[i].func_count; in ralink_pinctrl_index()
217 p->func_count++; in ralink_pinctrl_index()
220 p->func = devm_kcalloc(p->dev, p->func_count, in ralink_pinctrl_index()
221 sizeof(*p->func), GFP_KERNEL); in ralink_pinctrl_index()
222 gpio_func.groups = devm_kcalloc(p->dev, p->group_count, sizeof(int), in ralink_pinctrl_index()
224 if (!p->func || !gpio_func.groups) in ralink_pinctrl_index()
228 gpio_func.group_count = p->group_count; in ralink_pinctrl_index()
232 p->func[c] = &gpio_func; in ralink_pinctrl_index()
236 for (i = 0; i < p->group_count; i++) { in ralink_pinctrl_index()
237 for (j = 0; j < p->groups[i].func_count; j++) { in ralink_pinctrl_index()
238 p->func[c] = &p->groups[i].func[j]; in ralink_pinctrl_index()
239 p->func[c]->groups = devm_kzalloc(p->dev, sizeof(int), in ralink_pinctrl_index()
241 if (!p->func[c]->groups) in ralink_pinctrl_index()
243 p->func[c]->groups[0] = i; in ralink_pinctrl_index()
244 p->func[c]->group_count = 1; in ralink_pinctrl_index()
251 static int ralink_pinctrl_pins(struct ralink_priv *p) in ralink_pinctrl_pins() argument
259 for (i = 0; i < p->func_count; i++) { in ralink_pinctrl_pins()
262 if (!p->func[i]->pin_count) in ralink_pinctrl_pins()
265 p->func[i]->pins = devm_kcalloc(p->dev, in ralink_pinctrl_pins()
266 p->func[i]->pin_count, in ralink_pinctrl_pins()
269 if (!p->func[i]->pins) in ralink_pinctrl_pins()
271 for (j = 0; j < p->func[i]->pin_count; j++) in ralink_pinctrl_pins()
272 p->func[i]->pins[j] = p->func[i]->pin_first + j; in ralink_pinctrl_pins()
274 pin = p->func[i]->pin_first + p->func[i]->pin_count; in ralink_pinctrl_pins()
275 if (pin > p->max_pins) in ralink_pinctrl_pins()
276 p->max_pins = pin; in ralink_pinctrl_pins()
280 p->gpio = devm_kcalloc(p->dev, p->max_pins, sizeof(u8), GFP_KERNEL); in ralink_pinctrl_pins()
282 p->pads = devm_kcalloc(p->dev, p->max_pins, in ralink_pinctrl_pins()
284 if (!p->pads || !p->gpio) in ralink_pinctrl_pins()
287 memset(p->gpio, 1, sizeof(u8) * p->max_pins); in ralink_pinctrl_pins()
288 for (i = 0; i < p->func_count; i++) { in ralink_pinctrl_pins()
289 if (!p->func[i]->pin_count) in ralink_pinctrl_pins()
292 for (j = 0; j < p->func[i]->pin_count; j++) in ralink_pinctrl_pins()
293 p->gpio[p->func[i]->pins[j]] = 0; in ralink_pinctrl_pins()
297 p->gpio[0] = 1; in ralink_pinctrl_pins()
300 for (i = 0; i < p->max_pins; i++) { in ralink_pinctrl_pins()
302 char *name = devm_kzalloc(p->dev, 5, GFP_KERNEL); in ralink_pinctrl_pins()
307 p->pads[i].number = i; in ralink_pinctrl_pins()
308 p->pads[i].name = name; in ralink_pinctrl_pins()
310 p->desc->pins = p->pads; in ralink_pinctrl_pins()
311 p->desc->npins = p->max_pins; in ralink_pinctrl_pins()
319 struct ralink_priv *p; in ralink_pinctrl_init() local
327 p = devm_kzalloc(&pdev->dev, sizeof(struct ralink_priv), GFP_KERNEL); in ralink_pinctrl_init()
328 if (!p) in ralink_pinctrl_init()
331 p->dev = &pdev->dev; in ralink_pinctrl_init()
332 p->desc = &ralink_pctrl_desc; in ralink_pinctrl_init()
333 p->groups = data; in ralink_pinctrl_init()
334 platform_set_drvdata(pdev, p); in ralink_pinctrl_init()
337 err = ralink_pinctrl_index(p); in ralink_pinctrl_init()
343 err = ralink_pinctrl_pins(p); in ralink_pinctrl_init()
348 dev = pinctrl_register(p->desc, &pdev->dev, p); in ralink_pinctrl_init()