162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Pinctrl for Cirrus Logic CS47L85
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2016-2017 Cirrus Logic
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include <linux/err.h>
962306a36Sopenharmony_ci#include <linux/mfd/madera/core.h>
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include "pinctrl-madera.h"
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/*
1462306a36Sopenharmony_ci * The alt func groups are the most commonly used functions we place these at
1562306a36Sopenharmony_ci * the lower function indexes for convenience, and the less commonly used gpio
1662306a36Sopenharmony_ci * functions at higher indexes.
1762306a36Sopenharmony_ci *
1862306a36Sopenharmony_ci * To stay consistent with the datasheet the function names are the same as
1962306a36Sopenharmony_ci * the group names for that function's pins
2062306a36Sopenharmony_ci *
2162306a36Sopenharmony_ci * Note - all 1 less than in datasheet because these are zero-indexed
2262306a36Sopenharmony_ci */
2362306a36Sopenharmony_cistatic const unsigned int cs47l85_mif1_pins[] = { 8, 9 };
2462306a36Sopenharmony_cistatic const unsigned int cs47l85_mif2_pins[] = { 10, 11 };
2562306a36Sopenharmony_cistatic const unsigned int cs47l85_mif3_pins[] = { 12, 13 };
2662306a36Sopenharmony_cistatic const unsigned int cs47l85_aif1_pins[] = { 14, 15, 16, 17 };
2762306a36Sopenharmony_cistatic const unsigned int cs47l85_aif2_pins[] = { 18, 19, 20, 21 };
2862306a36Sopenharmony_cistatic const unsigned int cs47l85_aif3_pins[] = { 22, 23, 24, 25 };
2962306a36Sopenharmony_cistatic const unsigned int cs47l85_aif4_pins[] = { 26, 27, 28, 29 };
3062306a36Sopenharmony_cistatic const unsigned int cs47l85_dmic4_pins[] = { 30, 31 };
3162306a36Sopenharmony_cistatic const unsigned int cs47l85_dmic5_pins[] = { 32, 33 };
3262306a36Sopenharmony_cistatic const unsigned int cs47l85_dmic6_pins[] = { 34, 35 };
3362306a36Sopenharmony_cistatic const unsigned int cs47l85_spk1_pins[] = { 36, 38 };
3462306a36Sopenharmony_cistatic const unsigned int cs47l85_spk2_pins[] = { 37, 39 };
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_cistatic const struct madera_pin_groups cs47l85_pin_groups[] = {
3762306a36Sopenharmony_ci	{ "aif1", cs47l85_aif1_pins, ARRAY_SIZE(cs47l85_aif1_pins) },
3862306a36Sopenharmony_ci	{ "aif2", cs47l85_aif2_pins, ARRAY_SIZE(cs47l85_aif2_pins) },
3962306a36Sopenharmony_ci	{ "aif3", cs47l85_aif3_pins, ARRAY_SIZE(cs47l85_aif3_pins) },
4062306a36Sopenharmony_ci	{ "aif4", cs47l85_aif4_pins, ARRAY_SIZE(cs47l85_aif4_pins) },
4162306a36Sopenharmony_ci	{ "mif1", cs47l85_mif1_pins, ARRAY_SIZE(cs47l85_mif1_pins) },
4262306a36Sopenharmony_ci	{ "mif2", cs47l85_mif2_pins, ARRAY_SIZE(cs47l85_mif2_pins) },
4362306a36Sopenharmony_ci	{ "mif3", cs47l85_mif3_pins, ARRAY_SIZE(cs47l85_mif3_pins) },
4462306a36Sopenharmony_ci	{ "dmic4", cs47l85_dmic4_pins, ARRAY_SIZE(cs47l85_dmic4_pins) },
4562306a36Sopenharmony_ci	{ "dmic5", cs47l85_dmic5_pins, ARRAY_SIZE(cs47l85_dmic5_pins) },
4662306a36Sopenharmony_ci	{ "dmic6", cs47l85_dmic6_pins, ARRAY_SIZE(cs47l85_dmic6_pins) },
4762306a36Sopenharmony_ci	{ "pdmspk1", cs47l85_spk1_pins, ARRAY_SIZE(cs47l85_spk1_pins) },
4862306a36Sopenharmony_ci	{ "pdmspk2", cs47l85_spk2_pins, ARRAY_SIZE(cs47l85_spk2_pins) },
4962306a36Sopenharmony_ci};
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ciconst struct madera_pin_chip cs47l85_pin_chip = {
5262306a36Sopenharmony_ci	.n_pins = CS47L85_NUM_GPIOS,
5362306a36Sopenharmony_ci	.pin_groups = cs47l85_pin_groups,
5462306a36Sopenharmony_ci	.n_pin_groups = ARRAY_SIZE(cs47l85_pin_groups),
5562306a36Sopenharmony_ci};
56