Skip to content

Commit 793bef5

Browse files
Ladislav Michltsbogend
authored andcommitted
MIPS: OCTEON: octeon-usb: move gpio config to separate function
Power gpio configuration is using Octeon specific code, so move it to separate function, that can later be guarded with ifdefs. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
1 parent 940692c commit 793bef5

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

arch/mips/cavium-octeon/octeon-usb.c

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,35 @@ static DEFINE_MUTEX(dwc3_octeon_clocks_mutex);
197197
static uint8_t clk_div[OCTEON_H_CLKDIV_SEL] = {1, 2, 4, 6, 8, 16, 24, 32};
198198

199199

200-
static int dwc3_octeon_config_power(struct device *dev, u64 base)
200+
static void dwc3_octeon_config_gpio(int index, int gpio)
201201
{
202202
union cvmx_gpio_bit_cfgx gpio_bit;
203+
204+
if ((OCTEON_IS_MODEL(OCTEON_CN73XX) ||
205+
OCTEON_IS_MODEL(OCTEON_CNF75XX))
206+
&& gpio <= 31) {
207+
gpio_bit.u64 = cvmx_read_csr(CVMX_GPIO_BIT_CFGX(gpio));
208+
gpio_bit.s.tx_oe = 1;
209+
gpio_bit.s.output_sel = (index == 0 ? 0x14 : 0x15);
210+
cvmx_write_csr(CVMX_GPIO_BIT_CFGX(gpio), gpio_bit.u64);
211+
} else if (gpio <= 15) {
212+
gpio_bit.u64 = cvmx_read_csr(CVMX_GPIO_BIT_CFGX(gpio));
213+
gpio_bit.s.tx_oe = 1;
214+
gpio_bit.s.output_sel = (index == 0 ? 0x14 : 0x19);
215+
cvmx_write_csr(CVMX_GPIO_BIT_CFGX(gpio), gpio_bit.u64);
216+
} else {
217+
gpio_bit.u64 = cvmx_read_csr(CVMX_GPIO_XBIT_CFGX(gpio));
218+
gpio_bit.s.tx_oe = 1;
219+
gpio_bit.s.output_sel = (index == 0 ? 0x14 : 0x19);
220+
cvmx_write_csr(CVMX_GPIO_XBIT_CFGX(gpio), gpio_bit.u64);
221+
}
222+
}
223+
224+
static int dwc3_octeon_config_power(struct device *dev, u64 base)
225+
{
203226
uint32_t gpio_pwr[3];
204227
int gpio, len, power_active_low;
205228
struct device_node *node = dev->of_node;
206-
int index = (base >> 24) & 1;
207229
u64 val;
208230
u64 uctl_host_cfg_reg = base + USBDRD_UCTL_HOST_CFG;
209231

@@ -220,24 +242,7 @@ static int dwc3_octeon_config_power(struct device *dev, u64 base)
220242
dev_err(dev, "invalid power configuration\n");
221243
return -EINVAL;
222244
}
223-
if ((OCTEON_IS_MODEL(OCTEON_CN73XX) ||
224-
OCTEON_IS_MODEL(OCTEON_CNF75XX))
225-
&& gpio <= 31) {
226-
gpio_bit.u64 = cvmx_read_csr(CVMX_GPIO_BIT_CFGX(gpio));
227-
gpio_bit.s.tx_oe = 1;
228-
gpio_bit.s.output_sel = (index == 0 ? 0x14 : 0x15);
229-
cvmx_write_csr(CVMX_GPIO_BIT_CFGX(gpio), gpio_bit.u64);
230-
} else if (gpio <= 15) {
231-
gpio_bit.u64 = cvmx_read_csr(CVMX_GPIO_BIT_CFGX(gpio));
232-
gpio_bit.s.tx_oe = 1;
233-
gpio_bit.s.output_sel = (index == 0 ? 0x14 : 0x19);
234-
cvmx_write_csr(CVMX_GPIO_BIT_CFGX(gpio), gpio_bit.u64);
235-
} else {
236-
gpio_bit.u64 = cvmx_read_csr(CVMX_GPIO_XBIT_CFGX(gpio));
237-
gpio_bit.s.tx_oe = 1;
238-
gpio_bit.s.output_sel = (index == 0 ? 0x14 : 0x19);
239-
cvmx_write_csr(CVMX_GPIO_XBIT_CFGX(gpio), gpio_bit.u64);
240-
}
245+
dwc3_octeon_config_gpio((base >> 24) & 1, gpio);
241246

242247
/* Enable XHCI power control and set if active high or low. */
243248
val = cvmx_read_csr(uctl_host_cfg_reg);

0 commit comments

Comments
 (0)