diff options
author | John Crispin <blogic@openwrt.org> | 2012-12-15 01:59:45 +0000 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2012-12-15 01:59:45 +0000 |
commit | 48db0765a608660ca54014e7b579c9de7b423590 (patch) | |
tree | b01c98dfee8ccdd18862f3049d7dfdcca7828c3a /target/linux/lantiq/patches-3.7/0006-MIPS-lantiq-adds-GPHY-firmware-loader.patch | |
parent | 39d02a1398afb88290273276c545a0e9c267f69b (diff) | |
download | upstream-48db0765a608660ca54014e7b579c9de7b423590.tar.gz upstream-48db0765a608660ca54014e7b579c9de7b423590.tar.bz2 upstream-48db0765a608660ca54014e7b579c9de7b423590.zip |
[lantiq] add linux-v3.7
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34687 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/lantiq/patches-3.7/0006-MIPS-lantiq-adds-GPHY-firmware-loader.patch')
-rw-r--r-- | target/linux/lantiq/patches-3.7/0006-MIPS-lantiq-adds-GPHY-firmware-loader.patch | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/target/linux/lantiq/patches-3.7/0006-MIPS-lantiq-adds-GPHY-firmware-loader.patch b/target/linux/lantiq/patches-3.7/0006-MIPS-lantiq-adds-GPHY-firmware-loader.patch new file mode 100644 index 0000000000..56e43d552a --- /dev/null +++ b/target/linux/lantiq/patches-3.7/0006-MIPS-lantiq-adds-GPHY-firmware-loader.patch @@ -0,0 +1,144 @@ +From 0224cde212df4abf251f89c3724a800b1949a774 Mon Sep 17 00:00:00 2001 +From: John Crispin <blogic@openwrt.org> +Date: Mon, 22 Oct 2012 07:52:50 +0200 +Subject: [PATCH 6/6] MIPS: lantiq: adds GPHY firmware loader + +The internal GPHYs need a firmware blob to function properly. This patch adds +the code needed to request the blob and load it to the PHY. + +Signed-off-by: John Crispin <blogic@openwrt.org> +Patchwork: http://patchwork.linux-mips.org/patch/4523 +--- + arch/mips/lantiq/Kconfig | 4 ++ + arch/mips/lantiq/xway/Makefile | 2 + + arch/mips/lantiq/xway/xrx200_phy_fw.c | 97 +++++++++++++++++++++++++++++++++ + 3 files changed, 103 insertions(+) + create mode 100644 arch/mips/lantiq/xway/xrx200_phy_fw.c + +diff --git a/arch/mips/lantiq/Kconfig b/arch/mips/lantiq/Kconfig +index d84f361..c002191 100644 +--- a/arch/mips/lantiq/Kconfig ++++ b/arch/mips/lantiq/Kconfig +@@ -36,4 +36,8 @@ config PCI_LANTIQ + bool "PCI Support" + depends on SOC_XWAY && PCI + ++config XRX200_PHY_FW ++ bool "XRX200 PHY firmware loader" ++ depends on SOC_XWAY ++ + endif +diff --git a/arch/mips/lantiq/xway/Makefile b/arch/mips/lantiq/xway/Makefile +index 70a58c7..7a13660 100644 +--- a/arch/mips/lantiq/xway/Makefile ++++ b/arch/mips/lantiq/xway/Makefile +@@ -1 +1,3 @@ + obj-y := prom.o sysctrl.o clk.o reset.o dma.o gptu.o ++ ++obj-$(CONFIG_XRX200_PHY_FW) += xrx200_phy_fw.o +diff --git a/arch/mips/lantiq/xway/xrx200_phy_fw.c b/arch/mips/lantiq/xway/xrx200_phy_fw.c +new file mode 100644 +index 0000000..fe808bf +--- /dev/null ++++ b/arch/mips/lantiq/xway/xrx200_phy_fw.c +@@ -0,0 +1,97 @@ ++/* ++ * This program is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 as published ++ * by the Free Software Foundation. ++ * ++ * Copyright (C) 2012 John Crispin <blogic@openwrt.org> ++ */ ++ ++#include <linux/delay.h> ++#include <linux/dma-mapping.h> ++#include <linux/module.h> ++#include <linux/firmware.h> ++#include <linux/of_platform.h> ++ ++#include <lantiq_soc.h> ++ ++#define XRX200_GPHY_FW_ALIGN (16 * 1024) ++ ++static dma_addr_t xway_gphy_load(struct platform_device *pdev) ++{ ++ const struct firmware *fw; ++ dma_addr_t dev_addr = 0; ++ const char *fw_name; ++ void *fw_addr; ++ size_t size; ++ ++ if (of_property_read_string(pdev->dev.of_node, "firmware", &fw_name)) { ++ dev_err(&pdev->dev, "failed to load firmware filename\n"); ++ return 0; ++ } ++ ++ dev_info(&pdev->dev, "requesting %s\n", fw_name); ++ if (request_firmware(&fw, fw_name, &pdev->dev)) { ++ dev_err(&pdev->dev, "failed to load firmware: %s\n", fw_name); ++ return 0; ++ } ++ ++ /* ++ * GPHY cores need the firmware code in a persistent and contiguous ++ * memory area with a 16 kB boundary aligned start address ++ */ ++ size = fw->size + XRX200_GPHY_FW_ALIGN; ++ ++ fw_addr = dma_alloc_coherent(&pdev->dev, size, &dev_addr, GFP_KERNEL); ++ if (fw_addr) { ++ fw_addr = PTR_ALIGN(fw_addr, XRX200_GPHY_FW_ALIGN); ++ dev_addr = ALIGN(dev_addr, XRX200_GPHY_FW_ALIGN); ++ memcpy(fw_addr, fw->data, fw->size); ++ } else { ++ dev_err(&pdev->dev, "failed to alloc firmware memory\n"); ++ } ++ ++ release_firmware(fw); ++ return dev_addr; ++} ++ ++static int __devinit xway_phy_fw_probe(struct platform_device *pdev) ++{ ++ dma_addr_t fw_addr; ++ struct property *pp; ++ unsigned char *phyids; ++ int i, ret = 0; ++ ++ fw_addr = xway_gphy_load(pdev); ++ if (!fw_addr) ++ return -EINVAL; ++ pp = of_find_property(pdev->dev.of_node, "phys", NULL); ++ if (!pp) ++ return -ENOENT; ++ phyids = pp->value; ++ for (i = 0; i < pp->length && !ret; i++) ++ ret = xrx200_gphy_boot(&pdev->dev, phyids[i], fw_addr); ++ if (!ret) ++ mdelay(100); ++ return ret; ++} ++ ++static const struct of_device_id xway_phy_match[] = { ++ { .compatible = "lantiq,phy-xrx200" }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(of, xway_phy_match); ++ ++static struct platform_driver xway_phy_driver = { ++ .probe = xway_phy_fw_probe, ++ .driver = { ++ .name = "phy-xrx200", ++ .owner = THIS_MODULE, ++ .of_match_table = xway_phy_match, ++ }, ++}; ++ ++module_platform_driver(xway_phy_driver); ++ ++MODULE_AUTHOR("John Crispin <blogic@openwrt.org>"); ++MODULE_DESCRIPTION("Lantiq XRX200 PHY Firmware Loader"); ++MODULE_LICENSE("GPL"); +-- +1.7.10.4 + |