diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/led/core.c | 64 | ||||
-rw-r--r-- | drivers/led/led-triggers.c | 25 | ||||
-rw-r--r-- | drivers/mci/imx-esdhc-pbl.c | 64 | ||||
-rw-r--r-- | drivers/net/fsl-fman.c | 8 | ||||
-rw-r--r-- | drivers/pci/pci-layerscape.c | 53 | ||||
-rw-r--r-- | drivers/usb/host/ehci-hcd.c | 15 |
6 files changed, 111 insertions, 118 deletions
diff --git a/drivers/led/core.c b/drivers/led/core.c index 431966d067..e727148a24 100644 --- a/drivers/led/core.c +++ b/drivers/led/core.c @@ -256,37 +256,55 @@ void led_unregister(struct led *led) list_del(&led->list); } -struct led_trg { - const char *str; - enum led_trigger trg; +static char *trigger_names[] = { + [LED_TRIGGER_PANIC] = "panic", + [LED_TRIGGER_HEARTBEAT] = "heartbeat", + [LED_TRIGGER_NET_RX] = "net-rx", + [LED_TRIGGER_NET_TX] = "net-tx", + [LED_TRIGGER_NET_TXRX] = "net", + [LED_TRIGGER_DEFAULT_ON] = "default-on", }; -static struct led_trg triggers[] = { - { .str = "heartbeat", LED_TRIGGER_HEARTBEAT, }, - { .str = "panic", LED_TRIGGER_PANIC, }, - { .str = "net", LED_TRIGGER_NET_TXRX, }, - { .str = "default-on", LED_TRIGGER_DEFAULT_ON, }, -}; +const char *trigger_name(enum led_trigger trigger) +{ + return trigger_names[trigger]; +} + +enum led_trigger trigger_by_name(const char *name) +{ + int i; + + if (!name) + return LED_TRIGGER_MAX; + + for (i = 0; i < LED_TRIGGER_MAX; i++) + if (!strcmp(name, trigger_names[i])) + return i; + + return LED_TRIGGER_MAX; +} void led_of_parse_trigger(struct led *led, struct device_node *np) { + enum led_trigger trg = LED_TRIGGER_MAX; const char *trigger; - int i; - trigger = of_get_property(np, "linux,default-trigger", NULL); - if (!trigger) - trigger = of_get_property(np, "barebox,default-trigger", NULL); + if (of_property_read_bool(np, "panic-indicator")) + trg = LED_TRIGGER_PANIC; + + if (trg == LED_TRIGGER_MAX) { + trigger = of_get_property(np, "linux,default-trigger", NULL); + trg = trigger_by_name(trigger); + } - if (!trigger) - return; + if (trg == LED_TRIGGER_MAX) { + trigger = of_get_property(np, "barebox,default-trigger", NULL); + trg = trigger_by_name(trigger); + } - for (i = 0; i < ARRAY_SIZE(triggers); i++) { - struct led_trg *trg = &triggers[i]; - if (!strcmp(trg->str, trigger)) { - /* disable LED before installing trigger */ - led_set(led, 0); - led_set_trigger(trg->trg, led); - return; - } + if (trg != LED_TRIGGER_MAX) { + /* disable LED before installing trigger */ + led_set(led, 0); + led_set_trigger(trg, led); } } diff --git a/drivers/led/led-triggers.c b/drivers/led/led-triggers.c index 76a1481e14..216c8639bc 100644 --- a/drivers/led/led-triggers.c +++ b/drivers/led/led-triggers.c @@ -143,31 +143,6 @@ int led_set_trigger(enum led_trigger trigger, struct led *led) return 0; } -static char *trigger_names[] = { - [LED_TRIGGER_PANIC] = "panic", - [LED_TRIGGER_HEARTBEAT] = "heartbeat", - [LED_TRIGGER_NET_RX] = "net-rx", - [LED_TRIGGER_NET_TX] = "net-tx", - [LED_TRIGGER_NET_TXRX] = "net", - [LED_TRIGGER_DEFAULT_ON] = "default-on", -}; - -const char *trigger_name(enum led_trigger trigger) -{ - return trigger_names[trigger]; -} - -enum led_trigger trigger_by_name(const char *name) -{ - int i; - - for (i = 0; i < LED_TRIGGER_MAX; i++) - if (!strcmp(name, trigger_names[i])) - return i; - - return LED_TRIGGER_MAX; -} - /** * led_triggers_show_info - Show information about all registered * triggers diff --git a/drivers/mci/imx-esdhc-pbl.c b/drivers/mci/imx-esdhc-pbl.c index c0d27fb7eb..2579cfd9d1 100644 --- a/drivers/mci/imx-esdhc-pbl.c +++ b/drivers/mci/imx-esdhc-pbl.c @@ -121,8 +121,8 @@ static int esdhc_search_header(struct fsl_esdhc_host *host, } static int -esdhc_start_image(struct fsl_esdhc_host *host, ptrdiff_t address, ptrdiff_t entry, - u32 offset) +esdhc_load_image(struct fsl_esdhc_host *host, ptrdiff_t address, + ptrdiff_t entry, u32 offset, bool start) { void *buf = (void *)address; @@ -177,6 +177,9 @@ esdhc_start_image(struct fsl_esdhc_host *host, ptrdiff_t address, ptrdiff_t entr pr_debug("Image loaded successfully\n"); + if (!start) + return 0; + bb = buf + ofs; sync_caches_for_execution(); @@ -254,22 +257,23 @@ int imx6_esdhc_start_image(int instance) imx_esdhc_init(&host, &data); - return esdhc_start_image(&host, 0x10000000, 0x10000000, 0); + return esdhc_load_image(&host, 0x10000000, 0x10000000, 0, true); } /** - * imx8_esdhc_start_image - Load and start an image from USDHC controller + * imx8_esdhc_load_image - Load and optionally start an image from USDHC controller * @instance: The USDHC controller instance (0..2) + * @start: Whether to directly start the loaded image * * This uses esdhc_start_image() to load an image from SD/MMC. It is * assumed that the image is the currently running barebox image (This * information is used to calculate the length of the image). The * image is started afterwards. * - * Return: If successful, this function does not return. A negative error - * code is returned when this function fails. + * Return: If successful, this function does not return (if directly started) + * or 0. A negative error code is returned when this function fails. */ -int imx8_esdhc_start_image(int instance) +int imx8_esdhc_load_image(int instance, bool start) { struct esdhc_soc_data data; struct fsl_esdhc_host host; @@ -279,50 +283,8 @@ int imx8_esdhc_start_image(int instance) if (ret) return ret; - return esdhc_start_image(&host, MX8MQ_DDR_CSD1_BASE_ADDR, - MX8MQ_ATF_BL33_BASE_ADDR, SZ_32K); -} - -int imx8_esdhc_load_piggy(int instance) -{ - void *buf, *piggy; - struct imx_flash_header_v2 *hdr = NULL; - struct esdhc_soc_data data; - struct fsl_esdhc_host host; - int ret, len; - int offset = SZ_32K; - - ret = imx8_esdhc_init(&host, &data, instance); - if (ret) - return ret; - - /* - * We expect to be running at MX8MQ_ATF_BL33_BASE_ADDR where the atf - * has jumped to. Use a temporary buffer where we won't overwrite - * ourselves. - */ - buf = (void *)MX8MQ_ATF_BL33_BASE_ADDR + SZ_32M; - - ret = esdhc_search_header(&host, &hdr, buf, &offset); - if (ret) - return ret; - - len = offset + hdr->boot_data.size + piggydata_size(); - len = ALIGN(len, SECTOR_SIZE); - - ret = esdhc_read_blocks(&host, buf, len); - - /* - * Calculate location of the piggydata at the offset loaded into RAM - */ - piggy = buf + offset + hdr->boot_data.size; - - /* - * Copy the piggydata where the uncompressing code expects it - */ - memcpy(input_data, piggy, piggydata_size()); - - return ret; + return esdhc_load_image(&host, MX8MQ_DDR_CSD1_BASE_ADDR, + MX8MQ_ATF_BL33_BASE_ADDR, SZ_32K, start); } #endif diff --git a/drivers/net/fsl-fman.c b/drivers/net/fsl-fman.c index 1aae58e494..6d54fcc7c9 100644 --- a/drivers/net/fsl-fman.c +++ b/drivers/net/fsl-fman.c @@ -1322,13 +1322,6 @@ static int fsl_fman_probe(struct device_d *dev) return 0; } -static void fsl_fman_remove(struct device_d *dev) -{ - struct ccsr_fman *reg = dev->priv; - - setbits_be32(®->fm_fpm.fmrstc, FMFP_RSTC_RFM); -} - static struct of_device_id fsl_fman_dt_ids[] = { { .compatible = "fsl,fman", @@ -1339,7 +1332,6 @@ static struct of_device_id fsl_fman_dt_ids[] = { static struct driver_d fman_driver = { .name = "fsl-fman", .probe = fsl_fman_probe, - .remove = fsl_fman_remove, .of_compatible = DRV_OF_COMPAT(fsl_fman_dt_ids), }; device_platform_driver(fman_driver); diff --git a/drivers/pci/pci-layerscape.c b/drivers/pci/pci-layerscape.c index ccdc025c2e..e20dd55b1f 100644 --- a/drivers/pci/pci-layerscape.c +++ b/drivers/pci/pci-layerscape.c @@ -336,13 +336,32 @@ static int __init ls_add_pcie_port(struct ls_pcie *pcie) return 0; } +static phandle ls_pcie_get_iommu_handle(struct device_node *np, phandle *handle) +{ + u32 arr[4]; + int ret; + + /* + * We expect an existing "iommu-map" property with bogus values. All we + * use from it is the phandle to the iommu. + */ + ret = of_property_read_u32_array(np, "iommu-map", arr, 4); + if (ret) + return -ENOENT; + + *handle = arr[1]; + + return 0; +} + static int ls_pcie_of_fixup(struct device_node *root, void *ctx) { struct ls_pcie *pcie = ctx; struct device_d *dev = pcie->pci.dev; struct device_node *np; + phandle iommu_handle = 0; char *name; - u32 *arr, phandle; + u32 *msi_map, *iommu_map, phandle; int nluts; int ret, i; u32 devid, stream_id; @@ -364,7 +383,14 @@ static int ls_pcie_of_fixup(struct device_node *root, void *ctx) return ret; } - arr = xmalloc(nluts * sizeof(u32) * 4); + ret = ls_pcie_get_iommu_handle(np, &iommu_handle); + if (ret) { + dev_err(pcie->pci.dev, "Unable to get iommu phandle\n"); + return ret; + } + + msi_map = xmalloc(nluts * sizeof(u32) * 4); + iommu_map = xmalloc(nluts * sizeof(u32) * 4); for (i = 0; i < nluts; i++) { u32 udr = lut_readl(pcie, PCIE_LUT_UDR(i)); @@ -376,10 +402,15 @@ static int ls_pcie_of_fixup(struct device_node *root, void *ctx) devid = udr >> 16; stream_id = ldr & 0x7fff; - arr[i * 4] = devid; - arr[i * 4 + 1] = phandle; - arr[i * 4 + 2] = stream_id; - arr[i * 4 + 3] = 1; + msi_map[i * 4] = devid; + msi_map[i * 4 + 1] = phandle; + msi_map[i * 4 + 2] = stream_id; + msi_map[i * 4 + 3] = 1; + + iommu_map[i * 4] = devid; + iommu_map[i * 4 + 1] = iommu_handle; + iommu_map[i * 4 + 2] = stream_id; + iommu_map[i * 4 + 3] = 1; } /* @@ -391,7 +422,11 @@ static int ls_pcie_of_fixup(struct device_node *root, void *ctx) * [devid] [phandle-to-msi-ctrl] [stream-id] [count]>; */ - ret = of_property_write_u32_array(np, "msi-map", arr, nluts * 4); + ret = of_property_write_u32_array(np, "msi-map", msi_map, nluts * 4); + if (ret) + goto out; + + ret = of_property_write_u32_array(np, "iommu-map", iommu_map, nluts * 4); if (ret) goto out; @@ -400,7 +435,9 @@ static int ls_pcie_of_fixup(struct device_node *root, void *ctx) ret = 0; out: - free(arr); + free(msi_map); + free(iommu_map); + return ret; } diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index f3be177ceb..417ae5df75 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -137,6 +137,15 @@ static struct descriptor { #define ehci_is_TDI() (ehci->flags & EHCI_HAS_TT) +static void memzero32(void *ptr, size_t size) +{ + uint32_t *ptr32 = ptr; + int i; + + for (i = 0; i < size / sizeof(uint32_t); i++) + ptr32[i] = 0x0; +} + static int handshake(uint32_t *ptr, uint32_t mask, uint32_t done, int usec) { uint32_t result; @@ -237,7 +246,7 @@ static int ehci_prepare_qtd(struct device_d *dev, if (ret) return ret; } else { - memset(td->qt_buffer, 0, sizeof(td->qt_buffer)); + memzero32(td->qt_buffer, sizeof(td->qt_buffer)); } return 0; @@ -318,7 +327,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer, qh->qh_endpt2 = cpu_to_hc32(endpt); qh->qh_curtd = 0; qh->qt_token = 0; - memset(qh->qt_buffer, 0, sizeof(qh->qt_buffer)); + memzero32(qh->qt_buffer, sizeof(qh->qt_buffer)); tdp = &qh->qt_next; @@ -854,7 +863,7 @@ static int ehci_init(struct usb_host *host) */ ehci->periodic_schedules = 0; periodic = ehci->periodic_queue; - memset(periodic, 0, sizeof(*periodic)); + memzero32(periodic, sizeof(*periodic)); periodic->qh_link = cpu_to_hc32(QH_LINK_TERMINATE); periodic->qt_next = cpu_to_hc32(QT_NEXT_TERMINATE); periodic->qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE); |