Lines Matching refs:p

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