18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Pinctrl for Cirrus Logic CS47L90
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2016-2017 Cirrus Logic
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <linux/err.h>
98c2ecf20Sopenharmony_ci#include <linux/mfd/madera/core.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include "pinctrl-madera.h"
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/*
148c2ecf20Sopenharmony_ci * The alt func groups are the most commonly used functions we place these at
158c2ecf20Sopenharmony_ci * the lower function indexes for convenience, and the less commonly used gpio
168c2ecf20Sopenharmony_ci * functions at higher indexes.
178c2ecf20Sopenharmony_ci *
188c2ecf20Sopenharmony_ci * To stay consistent with the datasheet the function names are the same as
198c2ecf20Sopenharmony_ci * the group names for that function's pins
208c2ecf20Sopenharmony_ci *
218c2ecf20Sopenharmony_ci * Note - all 1 less than in datasheet because these are zero-indexed
228c2ecf20Sopenharmony_ci */
238c2ecf20Sopenharmony_cistatic const unsigned int cs47l90_mif1_pins[] = { 8, 9 };
248c2ecf20Sopenharmony_cistatic const unsigned int cs47l90_mif2_pins[] = { 10, 11 };
258c2ecf20Sopenharmony_cistatic const unsigned int cs47l90_mif3_pins[] = { 12, 13 };
268c2ecf20Sopenharmony_cistatic const unsigned int cs47l90_aif1_pins[] = { 14, 15, 16, 17 };
278c2ecf20Sopenharmony_cistatic const unsigned int cs47l90_aif2_pins[] = { 18, 19, 20, 21 };
288c2ecf20Sopenharmony_cistatic const unsigned int cs47l90_aif3_pins[] = { 22, 23, 24, 25 };
298c2ecf20Sopenharmony_cistatic const unsigned int cs47l90_aif4_pins[] = { 26, 27, 28, 29 };
308c2ecf20Sopenharmony_cistatic const unsigned int cs47l90_dmic4_pins[] = { 30, 31 };
318c2ecf20Sopenharmony_cistatic const unsigned int cs47l90_dmic5_pins[] = { 32, 33 };
328c2ecf20Sopenharmony_cistatic const unsigned int cs47l90_dmic3_pins[] = { 34, 35 };
338c2ecf20Sopenharmony_cistatic const unsigned int cs47l90_spk1_pins[] = { 36, 37 };
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_cistatic const struct madera_pin_groups cs47l90_pin_groups[] = {
368c2ecf20Sopenharmony_ci	{ "aif1", cs47l90_aif1_pins, ARRAY_SIZE(cs47l90_aif1_pins) },
378c2ecf20Sopenharmony_ci	{ "aif2", cs47l90_aif2_pins, ARRAY_SIZE(cs47l90_aif2_pins) },
388c2ecf20Sopenharmony_ci	{ "aif3", cs47l90_aif3_pins, ARRAY_SIZE(cs47l90_aif3_pins) },
398c2ecf20Sopenharmony_ci	{ "aif4", cs47l90_aif4_pins, ARRAY_SIZE(cs47l90_aif4_pins) },
408c2ecf20Sopenharmony_ci	{ "mif1", cs47l90_mif1_pins, ARRAY_SIZE(cs47l90_mif1_pins) },
418c2ecf20Sopenharmony_ci	{ "mif2", cs47l90_mif2_pins, ARRAY_SIZE(cs47l90_mif2_pins) },
428c2ecf20Sopenharmony_ci	{ "mif3", cs47l90_mif3_pins, ARRAY_SIZE(cs47l90_mif3_pins) },
438c2ecf20Sopenharmony_ci	{ "dmic3", cs47l90_dmic3_pins, ARRAY_SIZE(cs47l90_dmic3_pins) },
448c2ecf20Sopenharmony_ci	{ "dmic4", cs47l90_dmic4_pins, ARRAY_SIZE(cs47l90_dmic4_pins) },
458c2ecf20Sopenharmony_ci	{ "dmic5", cs47l90_dmic5_pins, ARRAY_SIZE(cs47l90_dmic5_pins) },
468c2ecf20Sopenharmony_ci	{ "pdmspk1", cs47l90_spk1_pins, ARRAY_SIZE(cs47l90_spk1_pins) },
478c2ecf20Sopenharmony_ci};
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ciconst struct madera_pin_chip cs47l90_pin_chip = {
508c2ecf20Sopenharmony_ci	.n_pins = CS47L90_NUM_GPIOS,
518c2ecf20Sopenharmony_ci	.pin_groups = cs47l90_pin_groups,
528c2ecf20Sopenharmony_ci	.n_pin_groups = ARRAY_SIZE(cs47l90_pin_groups),
538c2ecf20Sopenharmony_ci};
54