forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/pinctrl/sirf/pinctrl-atlas7.c
....@@ -1,10 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * pinctrl pads, groups, functions for CSR SiRFatlasVII
34 *
45 * Copyright (c) 2011 - 2014 Cambridge Silicon Radio Limited, a CSR plc group
56 * company.
6
- *
7
- * Licensed under GPLv2 or later.
87 */
98
109 #include <linux/init.h>
....@@ -19,14 +18,13 @@
1918 #include <linux/of_device.h>
2019 #include <linux/of_platform.h>
2120 #include <linux/of_irq.h>
22
-#include <linux/of_gpio.h>
2321 #include <linux/pinctrl/machine.h>
2422 #include <linux/pinctrl/pinconf.h>
2523 #include <linux/pinctrl/pinctrl.h>
2624 #include <linux/pinctrl/pinmux.h>
2725 #include <linux/pinctrl/consumer.h>
2826 #include <linux/pinctrl/pinconf-generic.h>
29
-#include <linux/gpio.h>
27
+#include <linux/gpio/driver.h>
3028
3129 /* Definition of Pad&Mux Properties */
3230 #define N 0
....@@ -171,7 +169,7 @@
171169
172170 /**
173171 * struct atlas7_pad_conf - Atlas7 Pad Configuration
174
- * @id The ID of this Pad.
172
+ * @id: The ID of this Pad.
175173 * @type: The type of this Pad.
176174 * @mux_reg: The mux register offset.
177175 * This register contains the mux.
....@@ -212,7 +210,7 @@
212210 .ad_ctrl_bit = adb, \
213211 }
214212
215
-/**
213
+/*
216214 * struct atlas7_pad_status - Atlas7 Pad status
217215 */
218216 struct atlas7_pad_status {
....@@ -354,13 +352,9 @@
354352 int nbank;
355353 raw_spinlock_t lock;
356354 struct gpio_chip chip;
357
- struct atlas7_gpio_bank banks[0];
355
+ struct atlas7_gpio_bank banks[];
358356 };
359357
360
-/**
361
- * @dev: a pointer back to containing device
362
- * @virtbase: the offset to the controller in virtual memory
363
- */
364358 struct atlas7_pmx {
365359 struct device *dev;
366360 struct pinctrl_dev *pctl;
....@@ -378,7 +372,7 @@
378372 * refer to A7DA IO Summary - CS-314158-DD-4E.xls
379373 */
380374
381
-/*Pads in IOC RTC & TOP */
375
+/* Pads in IOC RTC & TOP */
382376 static const struct pinctrl_pin_desc atlas7_ioc_pads[] = {
383377 /* RTC PADs */
384378 PINCTRL_PIN(0, "rtc_gpio_0"),
....@@ -4783,10 +4777,10 @@
47834777
47844778 /**
47854779 * struct atlas7_pull_info - Atlas7 Pad pull info
4786
- * @type:The type of this Pad.
4787
- * @mask:The mas value of this pin's pull bits.
4788
- * @v2s: The map of pull register value to pull status.
4789
- * @s2v: The map of pull status to pull register value.
4780
+ * @pad_type: The type of this Pad.
4781
+ * @mask: The mas value of this pin's pull bits.
4782
+ * @v2s: The map of pull register value to pull status.
4783
+ * @s2v: The map of pull status to pull register value.
47904784 */
47914785 struct atlas7_pull_info {
47924786 u8 pad_type;
....@@ -4910,6 +4904,7 @@
49104904 * @type: The type of this Pad.
49114905 * @mask: The mask value of this pin's pull bits.
49124906 * @imval: The immediate value of drives trength register.
4907
+ * @reserved: Reserved space
49134908 */
49144909 struct atlas7_ds_info {
49154910 u8 type;
....@@ -5540,14 +5535,10 @@
55405535 {
55415536 struct atlas7_pmx *pmx = dev_get_drvdata(dev);
55425537 struct atlas7_pad_status *status;
5543
- struct atlas7_pad_config *conf;
55445538 int idx;
5545
- u32 bank;
55465539
55475540 for (idx = 0; idx < pmx->pctl_desc.npins; idx++) {
55485541 /* Get this Pad's descriptor from PINCTRL */
5549
- conf = &pmx->pctl_data->confs[idx];
5550
- bank = atlas7_pin_to_bank(idx);
55515542 status = &pmx->sleep_data[idx];
55525543
55535544 /* Restore Function selector */
....@@ -5615,7 +5606,7 @@
56155606 arch_initcall(atlas7_pinmux_init);
56165607
56175608
5618
-/**
5609
+/*
56195610 * The Following is GPIO Code
56205611 */
56215612 static inline struct
....@@ -6002,6 +5993,7 @@
60025993 struct gpio_chip *chip;
60035994 u32 nbank;
60045995 int ret, idx;
5996
+ struct gpio_irq_chip *girq;
60055997
60065998 ret = of_property_read_u32(np, "gpio-banks", &nbank);
60075999 if (ret) {
....@@ -6012,8 +6004,8 @@
60126004 }
60136005
60146006 /* retrieve gpio descriptor data */
6015
- a7gc = devm_kzalloc(&pdev->dev, sizeof(*a7gc) +
6016
- sizeof(struct atlas7_gpio_bank) * nbank, GFP_KERNEL);
6007
+ a7gc = devm_kzalloc(&pdev->dev, struct_size(a7gc, banks, nbank),
6008
+ GFP_KERNEL);
60176009 if (!a7gc)
60186010 return -ENOMEM;
60196011
....@@ -6054,24 +6046,15 @@
60546046 chip->of_gpio_n_cells = 2;
60556047 chip->parent = &pdev->dev;
60566048
6057
- /* Add gpio chip to system */
6058
- ret = gpiochip_add_data(chip, a7gc);
6059
- if (ret) {
6060
- dev_err(&pdev->dev,
6061
- "%s: error in probe function with status %d\n",
6062
- np->name, ret);
6063
- goto failed;
6064
- }
6065
-
6066
- /* Add gpio chip to irq subsystem */
6067
- ret = gpiochip_irqchip_add(chip, &atlas7_gpio_irq_chip,
6068
- 0, handle_level_irq, IRQ_TYPE_NONE);
6069
- if (ret) {
6070
- dev_err(&pdev->dev,
6071
- "could not connect irqchip to gpiochip\n");
6072
- goto failed;
6073
- }
6074
-
6049
+ girq = &chip->irq;
6050
+ girq->chip = &atlas7_gpio_irq_chip;
6051
+ girq->parent_handler = atlas7_gpio_handle_irq;
6052
+ girq->num_parents = nbank;
6053
+ girq->parents = devm_kcalloc(&pdev->dev, nbank,
6054
+ sizeof(*girq->parents),
6055
+ GFP_KERNEL);
6056
+ if (!girq->parents)
6057
+ return -ENOMEM;
60756058 for (idx = 0; idx < nbank; idx++) {
60766059 struct atlas7_gpio_bank *bank;
60776060
....@@ -6090,9 +6073,18 @@
60906073 goto failed;
60916074 }
60926075 bank->irq = ret;
6076
+ girq->parents[idx] = ret;
6077
+ }
6078
+ girq->default_type = IRQ_TYPE_NONE;
6079
+ girq->handler = handle_level_irq;
60936080
6094
- gpiochip_set_chained_irqchip(chip, &atlas7_gpio_irq_chip,
6095
- bank->irq, atlas7_gpio_handle_irq);
6081
+ /* Add gpio chip to system */
6082
+ ret = gpiochip_add_data(chip, a7gc);
6083
+ if (ret) {
6084
+ dev_err(&pdev->dev,
6085
+ "%pOF: error in probe function with status %d\n",
6086
+ np, ret);
6087
+ goto failed;
60966088 }
60976089
60986090 platform_set_drvdata(pdev, a7gc);