xref: /OK3568_Linux_fs/kernel/drivers/pinctrl/cirrus/pinctrl-cs47l15.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Pinctrl for Cirrus Logic CS47L15
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (C) 2018-2019 Cirrus Logic, Inc. and
6*4882a593Smuzhiyun  *                         Cirrus Logic International Semiconductor Ltd.
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #include <linux/err.h>
10*4882a593Smuzhiyun #include <linux/mfd/madera/core.h>
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #include "pinctrl-madera.h"
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun /*
15*4882a593Smuzhiyun  * The alt func groups are the most commonly used functions we place these at
16*4882a593Smuzhiyun  * the lower function indexes for convenience, and the less commonly used gpio
17*4882a593Smuzhiyun  * functions at higher indexes.
18*4882a593Smuzhiyun  *
19*4882a593Smuzhiyun  * To stay consistent with the datasheet the function names are the same as
20*4882a593Smuzhiyun  * the group names for that function's pins
21*4882a593Smuzhiyun  *
22*4882a593Smuzhiyun  * Note - all 1 less than in datasheet because these are zero-indexed
23*4882a593Smuzhiyun  */
24*4882a593Smuzhiyun static const unsigned int cs47l15_aif1_pins[] = { 0, 1, 2, 3 };
25*4882a593Smuzhiyun static const unsigned int cs47l15_aif2_pins[] = { 4, 5, 6, 7 };
26*4882a593Smuzhiyun static const unsigned int cs47l15_aif3_pins[] = { 8, 9, 10, 11 };
27*4882a593Smuzhiyun static const unsigned int cs47l15_spk1_pins[] = { 12, 13, 14 };
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun static const struct madera_pin_groups cs47l15_pin_groups[] = {
30*4882a593Smuzhiyun 	{ "aif1", cs47l15_aif1_pins, ARRAY_SIZE(cs47l15_aif1_pins) },
31*4882a593Smuzhiyun 	{ "aif2", cs47l15_aif2_pins, ARRAY_SIZE(cs47l15_aif2_pins) },
32*4882a593Smuzhiyun 	{ "aif3", cs47l15_aif3_pins, ARRAY_SIZE(cs47l15_aif3_pins) },
33*4882a593Smuzhiyun 	{ "pdmspk1", cs47l15_spk1_pins, ARRAY_SIZE(cs47l15_spk1_pins) },
34*4882a593Smuzhiyun };
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun const struct madera_pin_chip cs47l15_pin_chip = {
37*4882a593Smuzhiyun 	.n_pins = CS47L15_NUM_GPIOS,
38*4882a593Smuzhiyun 	.pin_groups = cs47l15_pin_groups,
39*4882a593Smuzhiyun 	.n_pin_groups = ARRAY_SIZE(cs47l15_pin_groups),
40*4882a593Smuzhiyun };
41