Skip to content

Commit 9cfa409

Browse files
jamieNguyenNVIDIAianmay81
authored andcommitted
NVIDIA: SAUCE: Revert "gpio: tegra186: Check GPIO pin permission before access."
BugLink: https://bugs.launchpad.net/bugs/2053148 This reverts commit b2b56a1. This commit causes a regression in the GPIO initialization routine on T241 (or Grace) systems. The tegra186_gpio_is_accessible() function incorrectly declares GPIO lines that have only one of TEGRA186_GPIO_SCR_SEC_REN _or_ TEGRA186_GPIO_SCR_SEC_WEN set as being inaccessible. Signed-off-by: Jamie Nguyen <[email protected]> Acked-by: Brad Figg <[email protected]> Acked-by: Jacob Martin <[email protected]> Signed-off-by: Ian May <[email protected]>
1 parent f09e166 commit 9cfa409

File tree

1 file changed

+0
-78
lines changed

1 file changed

+0
-78
lines changed

drivers/gpio/gpio-tegra186.c

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,6 @@
2727

2828
#define TEGRA186_GPIO_INT_ROUTE_MAPPING(p, x) (0x14 + (p) * 0x20 + (x) * 4)
2929

30-
#define TEGRA186_GPIO_VM 0x00
31-
#define TEGRA186_GPIO_VM_RW_MASK 0x03
32-
#define TEGRA186_GPIO_SCR 0x04
33-
#define TEGRA186_GPIO_SCR_PIN_SIZE 0x08
34-
#define TEGRA186_GPIO_SCR_PORT_SIZE 0x40
35-
#define TEGRA186_GPIO_SCR_SEC_WEN BIT(28)
36-
#define TEGRA186_GPIO_SCR_SEC_REN BIT(27)
37-
#define TEGRA186_GPIO_SCR_SEC_G1W BIT(9)
38-
#define TEGRA186_GPIO_SCR_SEC_G1R BIT(1)
39-
#define TEGRA186_GPIO_FULL_ACCESS (TEGRA186_GPIO_SCR_SEC_WEN | \
40-
TEGRA186_GPIO_SCR_SEC_REN | \
41-
TEGRA186_GPIO_SCR_SEC_G1R | \
42-
TEGRA186_GPIO_SCR_SEC_G1W)
43-
#define TEGRA186_GPIO_SCR_SEC_ENABLE (TEGRA186_GPIO_SCR_SEC_WEN | \
44-
TEGRA186_GPIO_SCR_SEC_REN)
45-
4630
/* control registers */
4731
#define TEGRA186_GPIO_ENABLE_CONFIG 0x00
4832
#define TEGRA186_GPIO_ENABLE_CONFIG_ENABLE BIT(0)
@@ -97,7 +81,6 @@ struct tegra_gpio_soc {
9781
unsigned int num_pin_ranges;
9882
const char *pinmux;
9983
bool has_gte;
100-
bool has_vm_support;
10184
};
10285

10386
struct tegra_gpio {
@@ -147,58 +130,6 @@ static void __iomem *tegra186_gpio_get_base(struct tegra_gpio *gpio,
147130
return gpio->base + offset + pin * 0x20;
148131
}
149132

150-
static void __iomem *tegra186_gpio_get_secure_base(struct tegra_gpio *gpio,
151-
unsigned int pin)
152-
{
153-
const struct tegra_gpio_port *port;
154-
unsigned int offset;
155-
156-
port = tegra186_gpio_get_port(gpio, &pin);
157-
if (!port)
158-
return NULL;
159-
160-
offset = port->bank * 0x1000 + port->port * TEGRA186_GPIO_SCR_PORT_SIZE;
161-
162-
return gpio->secure + offset + pin * TEGRA186_GPIO_SCR_PIN_SIZE;
163-
}
164-
165-
static inline bool tegra186_gpio_is_accessible(struct tegra_gpio *gpio, unsigned int pin)
166-
{
167-
void __iomem *secure;
168-
u32 value;
169-
170-
secure = tegra186_gpio_get_secure_base(gpio, pin);
171-
172-
if (gpio->soc->has_vm_support) {
173-
value = readl(secure + TEGRA186_GPIO_VM);
174-
if ((value & TEGRA186_GPIO_VM_RW_MASK) != TEGRA186_GPIO_VM_RW_MASK)
175-
return false;
176-
}
177-
178-
value = __raw_readl(secure + TEGRA186_GPIO_SCR);
179-
180-
if ((value & TEGRA186_GPIO_SCR_SEC_ENABLE) == 0)
181-
return true;
182-
183-
if ((value & TEGRA186_GPIO_FULL_ACCESS) == TEGRA186_GPIO_FULL_ACCESS)
184-
return true;
185-
186-
return false;
187-
}
188-
189-
static int tegra186_init_valid_mask(struct gpio_chip *chip,
190-
unsigned long *valid_mask, unsigned int ngpios)
191-
{
192-
struct tegra_gpio *gpio = gpiochip_get_data(chip);
193-
unsigned int j;
194-
195-
for (j = 0; j < ngpios; j++) {
196-
if (!tegra186_gpio_is_accessible(gpio, j))
197-
clear_bit(j, valid_mask);
198-
}
199-
return 0;
200-
}
201-
202133
static int tegra186_gpio_get_direction(struct gpio_chip *chip,
203134
unsigned int offset)
204135
{
@@ -885,7 +816,6 @@ static int tegra186_gpio_probe(struct platform_device *pdev)
885816
gpio->gpio.set = tegra186_gpio_set;
886817
gpio->gpio.set_config = tegra186_gpio_set_config;
887818
gpio->gpio.add_pin_ranges = tegra186_gpio_add_pin_ranges;
888-
gpio->gpio.init_valid_mask = tegra186_init_valid_mask;
889819
if (gpio->soc->has_gte) {
890820
gpio->gpio.en_hw_timestamp = tegra186_gpio_en_hw_ts;
891821
gpio->gpio.dis_hw_timestamp = tegra186_gpio_dis_hw_ts;
@@ -1032,7 +962,6 @@ static const struct tegra_gpio_soc tegra186_main_soc = {
1032962
.name = "tegra186-gpio",
1033963
.instance = 0,
1034964
.num_irqs_per_bank = 1,
1035-
.has_vm_support = false,
1036965
};
1037966

1038967
#define TEGRA186_AON_GPIO_PORT(_name, _bank, _port, _pins) \
@@ -1060,7 +989,6 @@ static const struct tegra_gpio_soc tegra186_aon_soc = {
1060989
.name = "tegra186-gpio-aon",
1061990
.instance = 1,
1062991
.num_irqs_per_bank = 1,
1063-
.has_vm_support = false,
1064992
};
1065993

1066994
#define TEGRA194_MAIN_GPIO_PORT(_name, _bank, _port, _pins) \
@@ -1116,7 +1044,6 @@ static const struct tegra_gpio_soc tegra194_main_soc = {
11161044
.num_pin_ranges = ARRAY_SIZE(tegra194_main_pin_ranges),
11171045
.pin_ranges = tegra194_main_pin_ranges,
11181046
.pinmux = "nvidia,tegra194-pinmux",
1119-
.has_vm_support = true,
11201047
};
11211048

11221049
#define TEGRA194_AON_GPIO_PORT(_name, _bank, _port, _pins) \
@@ -1142,7 +1069,6 @@ static const struct tegra_gpio_soc tegra194_aon_soc = {
11421069
.instance = 1,
11431070
.num_irqs_per_bank = 8,
11441071
.has_gte = true,
1145-
.has_vm_support = false,
11461072
};
11471073

11481074
#define TEGRA234_MAIN_GPIO_PORT(_name, _bank, _port, _pins) \
@@ -1187,7 +1113,6 @@ static const struct tegra_gpio_soc tegra234_main_soc = {
11871113
.name = "tegra234-gpio",
11881114
.instance = 0,
11891115
.num_irqs_per_bank = 8,
1190-
.has_vm_support = true,
11911116
};
11921117

11931118
#define TEGRA234_AON_GPIO_PORT(_name, _bank, _port, _pins) \
@@ -1214,7 +1139,6 @@ static const struct tegra_gpio_soc tegra234_aon_soc = {
12141139
.instance = 1,
12151140
.num_irqs_per_bank = 8,
12161141
.has_gte = true,
1217-
.has_vm_support = false,
12181142
};
12191143

12201144
#define TEGRA241_MAIN_GPIO_PORT(_name, _bank, _port, _pins) \
@@ -1245,7 +1169,6 @@ static const struct tegra_gpio_soc tegra241_main_soc = {
12451169
.name = "tegra241-gpio",
12461170
.instance = 0,
12471171
.num_irqs_per_bank = 8,
1248-
.has_vm_support = false,
12491172
};
12501173

12511174
#define TEGRA241_AON_GPIO_PORT(_name, _bank, _port, _pins) \
@@ -1267,7 +1190,6 @@ static const struct tegra_gpio_soc tegra241_aon_soc = {
12671190
.name = "tegra241-gpio-aon",
12681191
.instance = 1,
12691192
.num_irqs_per_bank = 8,
1270-
.has_vm_support = false,
12711193
};
12721194

12731195
static const struct of_device_id tegra186_gpio_of_match[] = {

0 commit comments

Comments
 (0)