mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-02-23 15:26:07 +07:00

This patch add support for the bcma bus. Broadcom uses only Mips 74K CPUs on the new SoC and on the old ons using ssb bus there are no Mips 74K CPUs. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Acked-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
102 lines
2.4 KiB
C
102 lines
2.4 KiB
C
/*
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
* for more details.
|
|
*
|
|
* Copyright (C) 2007 Aurelien Jarno <aurelien@aurel32.net>
|
|
*/
|
|
|
|
#include <linux/ssb/ssb.h>
|
|
#include <linux/ssb/ssb_driver_chipcommon.h>
|
|
#include <linux/ssb/ssb_driver_extif.h>
|
|
#include <asm/mach-bcm47xx/bcm47xx.h>
|
|
#include <asm/mach-bcm47xx/gpio.h>
|
|
|
|
#if (BCM47XX_CHIPCO_GPIO_LINES > BCM47XX_EXTIF_GPIO_LINES)
|
|
static DECLARE_BITMAP(gpio_in_use, BCM47XX_CHIPCO_GPIO_LINES);
|
|
#else
|
|
static DECLARE_BITMAP(gpio_in_use, BCM47XX_EXTIF_GPIO_LINES);
|
|
#endif
|
|
|
|
int gpio_request(unsigned gpio, const char *tag)
|
|
{
|
|
switch (bcm47xx_bus_type) {
|
|
#ifdef CONFIG_BCM47XX_SSB
|
|
case BCM47XX_BUS_TYPE_SSB:
|
|
if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco) &&
|
|
((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES))
|
|
return -EINVAL;
|
|
|
|
if (ssb_extif_available(&bcm47xx_bus.ssb.extif) &&
|
|
((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
|
|
return -EINVAL;
|
|
|
|
if (test_and_set_bit(gpio, gpio_in_use))
|
|
return -EBUSY;
|
|
|
|
return 0;
|
|
#endif
|
|
#ifdef CONFIG_BCM47XX_BCMA
|
|
case BCM47XX_BUS_TYPE_BCMA:
|
|
if (gpio >= BCM47XX_CHIPCO_GPIO_LINES)
|
|
return -EINVAL;
|
|
|
|
if (test_and_set_bit(gpio, gpio_in_use))
|
|
return -EBUSY;
|
|
|
|
return 0;
|
|
#endif
|
|
}
|
|
return -EINVAL;
|
|
}
|
|
EXPORT_SYMBOL(gpio_request);
|
|
|
|
void gpio_free(unsigned gpio)
|
|
{
|
|
switch (bcm47xx_bus_type) {
|
|
#ifdef CONFIG_BCM47XX_SSB
|
|
case BCM47XX_BUS_TYPE_SSB:
|
|
if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco) &&
|
|
((unsigned)gpio >= BCM47XX_CHIPCO_GPIO_LINES))
|
|
return;
|
|
|
|
if (ssb_extif_available(&bcm47xx_bus.ssb.extif) &&
|
|
((unsigned)gpio >= BCM47XX_EXTIF_GPIO_LINES))
|
|
return;
|
|
|
|
clear_bit(gpio, gpio_in_use);
|
|
return;
|
|
#endif
|
|
#ifdef CONFIG_BCM47XX_BCMA
|
|
case BCM47XX_BUS_TYPE_BCMA:
|
|
if (gpio >= BCM47XX_CHIPCO_GPIO_LINES)
|
|
return;
|
|
|
|
clear_bit(gpio, gpio_in_use);
|
|
return;
|
|
#endif
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(gpio_free);
|
|
|
|
int gpio_to_irq(unsigned gpio)
|
|
{
|
|
switch (bcm47xx_bus_type) {
|
|
#ifdef CONFIG_BCM47XX_SSB
|
|
case BCM47XX_BUS_TYPE_SSB:
|
|
if (ssb_chipco_available(&bcm47xx_bus.ssb.chipco))
|
|
return ssb_mips_irq(bcm47xx_bus.ssb.chipco.dev) + 2;
|
|
else if (ssb_extif_available(&bcm47xx_bus.ssb.extif))
|
|
return ssb_mips_irq(bcm47xx_bus.ssb.extif.dev) + 2;
|
|
else
|
|
return -EINVAL;
|
|
#endif
|
|
#ifdef CONFIG_BCM47XX_BCMA
|
|
case BCM47XX_BUS_TYPE_BCMA:
|
|
return bcma_core_mips_irq(bcm47xx_bus.bcma.bus.drv_cc.core) + 2;
|
|
#endif
|
|
}
|
|
return -EINVAL;
|
|
}
|
|
EXPORT_SYMBOL_GPL(gpio_to_irq);
|