summaryrefslogtreecommitdiffstats
path: root/sys/mips/mediatek
diff options
context:
space:
mode:
authorsgalabov <sgalabov@FreeBSD.org>2016-04-15 15:24:42 +0000
committersgalabov <sgalabov@FreeBSD.org>2016-04-15 15:24:42 +0000
commitd88d83a49f1b40990323949301473922b54381b7 (patch)
treed599cdd520ffc0c77f5efe8395bc11c8d17316d7 /sys/mips/mediatek
parentdbbcd0a8249843e57be9c9b065a2eae272bc3ba8 (diff)
downloadFreeBSD-src-d88d83a49f1b40990323949301473922b54381b7.zip
FreeBSD-src-d88d83a49f1b40990323949301473922b54381b7.tar.gz
Mediatek/Ralink: Get our drivers closer to OpenWRT dts definitions
This revision gets our Mediatek/Ralink drivers closer to OpenWRT's dts definitions, so we can reuse them with less modifications later in order to bring support for a lot of boards at once. Approved by: adrian (mentor) Sponsored by: Smartcom - Bulgaria AD Differential Revision: https://reviews.freebsd.org/D5961
Diffstat (limited to 'sys/mips/mediatek')
-rw-r--r--sys/mips/mediatek/mtk_ehci.c2
-rw-r--r--sys/mips/mediatek/mtk_gpio_v1.c4
-rw-r--r--sys/mips/mediatek/mtk_gpio_v2.c6
-rw-r--r--sys/mips/mediatek/mtk_intr_gic.c4
-rw-r--r--sys/mips/mediatek/mtk_ohci.c2
-rw-r--r--sys/mips/mediatek/mtk_pcie.c41
-rw-r--r--sys/mips/mediatek/mtk_soc.c1
-rw-r--r--sys/mips/mediatek/mtk_usb_phy.c5
-rw-r--r--sys/mips/mediatek/mtk_xhci.c2
9 files changed, 38 insertions, 29 deletions
diff --git a/sys/mips/mediatek/mtk_ehci.c b/sys/mips/mediatek/mtk_ehci.c
index 109a32a..acc30eb 100644
--- a/sys/mips/mediatek/mtk_ehci.c
+++ b/sys/mips/mediatek/mtk_ehci.c
@@ -78,7 +78,7 @@ ehci_fdt_probe(device_t self)
if (!ofw_bus_status_okay(self))
return (ENXIO);
- if (!ofw_bus_is_compatible(self, "ralink,rt3xxx-ehci"))
+ if (!ofw_bus_is_compatible(self, "generic-ehci"))
return (ENXIO);
device_set_desc(self, EHCI_HC_DEVSTR);
diff --git a/sys/mips/mediatek/mtk_gpio_v1.c b/sys/mips/mediatek/mtk_gpio_v1.c
index 29b2258..ad3a0fc 100644
--- a/sys/mips/mediatek/mtk_gpio_v1.c
+++ b/sys/mips/mediatek/mtk_gpio_v1.c
@@ -281,8 +281,8 @@ mtk_gpio_attach(device_t dev)
sc->do_remap = 0;
}
- if (OF_hasprop(node, "mtk,num-pins") && (OF_getencprop(node,
- "mtk,num-pins", &num_pins, sizeof(num_pins)) >= 0))
+ if (OF_hasprop(node, "ralink,num-gpios") && (OF_getencprop(node,
+ "ralink,num-gpios", &num_pins, sizeof(num_pins)) >= 0))
sc->num_pins = num_pins;
else
sc->num_pins = MTK_GPIO_PINS;
diff --git a/sys/mips/mediatek/mtk_gpio_v2.c b/sys/mips/mediatek/mtk_gpio_v2.c
index 282b112..c7c0326 100644
--- a/sys/mips/mediatek/mtk_gpio_v2.c
+++ b/sys/mips/mediatek/mtk_gpio_v2.c
@@ -121,8 +121,8 @@ static int mtk_gpio_intr(void *arg);
#define GPIO_PIORESET(_sc) GPIO_REG((_sc), 0x0040)
static struct ofw_compat_data compat_data[] = {
- { "mtk,mt7621-gpio", 1 },
- { "mtk,mt7628-gpio", 1 },
+ { "mtk,mt7621-gpio-bank", 1 },
+ { "mtk,mt7628-gpio-bank", 1 },
{ NULL, 0 }
};
@@ -281,7 +281,7 @@ mtk_gpio_attach(device_t dev)
else
sc->num_pins = MTK_GPIO_PINS;
- for (i = 0; i < num_pins; i++) {
+ for (i = 0; i < sc->num_pins; i++) {
sc->pins[i].pin_caps |= GPIO_PIN_INPUT | GPIO_PIN_OUTPUT |
GPIO_PIN_INVIN | GPIO_PIN_INVOUT;
sc->pins[i].intr_polarity = INTR_POLARITY_HIGH;
diff --git a/sys/mips/mediatek/mtk_intr_gic.c b/sys/mips/mediatek/mtk_intr_gic.c
index 3eb6ffc..ab96cac 100644
--- a/sys/mips/mediatek/mtk_intr_gic.c
+++ b/sys/mips/mediatek/mtk_intr_gic.c
@@ -281,10 +281,10 @@ mtk_gic_map_intr(device_t dev, struct intr_map_data *data,
sc = device_get_softc(dev);
if (data == NULL || data->type != INTR_MAP_DATA_FDT ||
- data->fdt.ncells != 1 || data->fdt.cells[0] >= sc->nirqs)
+ data->fdt.ncells != 3 || data->fdt.cells[1] >= sc->nirqs)
return (EINVAL);
- *isrcp = GIC_INTR_ISRC(sc, data->fdt.cells[0]);
+ *isrcp = GIC_INTR_ISRC(sc, data->fdt.cells[1]);
return (0);
#else
return (EINVAL);
diff --git a/sys/mips/mediatek/mtk_ohci.c b/sys/mips/mediatek/mtk_ohci.c
index 91c98ce..0b554e7 100644
--- a/sys/mips/mediatek/mtk_ohci.c
+++ b/sys/mips/mediatek/mtk_ohci.c
@@ -78,7 +78,7 @@ ohci_fdt_probe(device_t self)
if (!ofw_bus_status_okay(self))
return (ENXIO);
- if (!ofw_bus_is_compatible(self, "ralink,rt3xxx-ohci"))
+ if (!ofw_bus_is_compatible(self, "generic-ohci"))
return (ENXIO);
device_set_desc(self, OHCI_HC_DEVSTR);
diff --git a/sys/mips/mediatek/mtk_pcie.c b/sys/mips/mediatek/mtk_pcie.c
index e88b9ab..66d8add 100644
--- a/sys/mips/mediatek/mtk_pcie.c
+++ b/sys/mips/mediatek/mtk_pcie.c
@@ -99,7 +99,7 @@ struct mtk_pci_range {
u_long len;
};
-#define FDT_RANGES_CELLS (3 * 2)
+#define FDT_RANGES_CELLS ((1 + 2 + 3) * 2)
static void
mtk_pci_range_dump(struct mtk_pci_range *range)
@@ -117,30 +117,33 @@ mtk_pci_ranges_decode(phandle_t node, struct mtk_pci_range *io_space,
{
struct mtk_pci_range *pci_space;
pcell_t ranges[FDT_RANGES_CELLS];
+ pcell_t addr_cells, size_cells, par_addr_cells;
pcell_t *rangesptr;
pcell_t cell0, cell1, cell2;
- int tuples, i, rv, len;
+ int tuple_size, tuples, i, rv, len;
/*
* Retrieve 'ranges' property.
*/
- if (!OF_hasprop(node, "ranges")) {
- printf("%s: %d\n", __FUNCTION__, 1);
+ if ((fdt_addrsize_cells(node, &addr_cells, &size_cells)) != 0)
return (EINVAL);
- }
+ if (addr_cells != 3 || size_cells != 2)
+ return (ERANGE);
+
+ par_addr_cells = fdt_parent_addr_cells(node);
+ if (par_addr_cells != 1)
+ return (ERANGE);
len = OF_getproplen(node, "ranges");
- if (len > sizeof(ranges)) {
- printf("%s: %d\n", __FUNCTION__, 2);
+ if (len > sizeof(ranges))
return (ENOMEM);
- }
- if (OF_getprop(node, "ranges", ranges, sizeof(ranges)) <= 0) {
- printf("%s: %d\n", __FUNCTION__, 3);
+ if (OF_getprop(node, "ranges", ranges, sizeof(ranges)) <= 0)
return (EINVAL);
- }
- tuples = len / (sizeof(pcell_t) * 3);
+ tuple_size = sizeof(pcell_t) * (addr_cells + par_addr_cells +
+ size_cells);
+ tuples = len / tuple_size;
/*
* Initialize the ranges so that we don't have to worry about
@@ -159,18 +162,21 @@ mtk_pci_ranges_decode(phandle_t node, struct mtk_pci_range *io_space,
cell2 = fdt_data_get((void *)rangesptr, 1);
rangesptr++;
- if (cell0 == 2) {
+ if (cell0 & 0x02000000) {
pci_space = mem_space;
- } else if (cell0 == 1) {
+ } else if (cell0 & 0x01000000) {
pci_space = io_space;
} else {
rv = ERANGE;
- printf("%s: %d\n", __FUNCTION__, 4);
goto out;
}
- pci_space->base = cell1;
- pci_space->len = cell2;
+ pci_space->base = fdt_data_get((void *)rangesptr,
+ par_addr_cells);
+ rangesptr += par_addr_cells;
+
+ pci_space->len = fdt_data_get((void *)rangesptr, size_cells);
+ rangesptr += size_cells;
}
rv = 0;
@@ -199,6 +205,7 @@ static struct ofw_compat_data compat_data[] = {
{ "ralink,rt3883-pcie", MTK_SOC_RT3883 },
{ "ralink,mt7620a-pcie", MTK_SOC_MT7620A },
{ "ralink,mt7621-pcie", MTK_SOC_MT7621 },
+ { "mediatek,mt7621-pci", MTK_SOC_MT7621 },
{ "ralink,mt7628-pcie", MTK_SOC_MT7628 },
{ "ralink,mt7688-pcie", MTK_SOC_MT7628 },
{ NULL, MTK_SOC_UNKNOWN }
diff --git a/sys/mips/mediatek/mtk_soc.c b/sys/mips/mediatek/mtk_soc.c
index b331467..5784fec 100644
--- a/sys/mips/mediatek/mtk_soc.c
+++ b/sys/mips/mediatek/mtk_soc.c
@@ -63,6 +63,7 @@ static const struct ofw_compat_data compat_data[] = {
{ "ralink,mtk7620a-soc", MTK_SOC_MT7620A },
{ "ralink,mtk7620n-soc", MTK_SOC_MT7620N },
{ "mediatek,mtk7621-soc", MTK_SOC_MT7621 },
+ { "mediatek,mt7621-soc", MTK_SOC_MT7621 },
{ "ralink,mtk7621-soc", MTK_SOC_MT7621 },
{ "ralink,mtk7628an-soc", MTK_SOC_MT7628 },
{ "mediatek,mt7628an-soc", MTK_SOC_MT7628 },
diff --git a/sys/mips/mediatek/mtk_usb_phy.c b/sys/mips/mediatek/mtk_usb_phy.c
index d400720..59b1ffd 100644
--- a/sys/mips/mediatek/mtk_usb_phy.c
+++ b/sys/mips/mediatek/mtk_usb_phy.c
@@ -84,9 +84,10 @@ static void mtk_usb_phy_mt7621_init(device_t);
static void mtk_usb_phy_mt7628_init(device_t);
static struct ofw_compat_data compat_data[] = {
- { "ralink,mt7620a-usbphy", MTK_SOC_MT7620A },
+ { "ralink,mt7620-usbphy", MTK_SOC_MT7620A },
{ "ralink,mt7628an-usbphy", MTK_SOC_MT7628 },
- { "ralink,rt3xxx-usbphy", MTK_SOC_RT3352 },
+ { "ralink,rt3352-usbphy", MTK_SOC_RT3352 },
+ { "ralink,rt3050-usbphy", MTK_SOC_RT3050 },
{ NULL, MTK_SOC_UNKNOWN }
};
diff --git a/sys/mips/mediatek/mtk_xhci.c b/sys/mips/mediatek/mtk_xhci.c
index 78328bb..138a4d4 100644
--- a/sys/mips/mediatek/mtk_xhci.c
+++ b/sys/mips/mediatek/mtk_xhci.c
@@ -80,7 +80,7 @@ mtk_xhci_fdt_probe(device_t self)
if (!ofw_bus_status_okay(self))
return (ENXIO);
- if (!ofw_bus_is_compatible(self, "mtk,usb-xhci"))
+ if (!ofw_bus_is_compatible(self, "mediatek,mt8173-xhci"))
return (ENXIO);
device_set_desc(self, XHCI_HC_DEVSTR);
OpenPOWER on IntegriCloud