diff --git a/config/kernel/linux-meson64-default.config b/config/kernel/linux-meson64-default.config index eda4597f6a..fb4a71f71e 100644 --- a/config/kernel/linux-meson64-default.config +++ b/config/kernel/linux-meson64-default.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm64 4.14.68 Kernel Configuration +# Linux/arm64 4.14.70 Kernel Configuration # CONFIG_ARM64=y CONFIG_64BIT=y @@ -447,15 +447,16 @@ CONFIG_SCHED_MC=y CONFIG_NR_CPUS=64 CONFIG_HOTPLUG_CPU=y # CONFIG_NUMA is not set +CONFIG_HOLES_IN_ZONE=y # CONFIG_PREEMPT_NONE is not set # CONFIG_PREEMPT_VOLUNTARY is not set CONFIG_PREEMPT=y CONFIG_PREEMPT_COUNT=y # CONFIG_HZ_100 is not set -# CONFIG_HZ_250 is not set +CONFIG_HZ_250=y # CONFIG_HZ_300 is not set -CONFIG_HZ_1000=y -CONFIG_HZ=1000 +# CONFIG_HZ_1000 is not set +CONFIG_HZ=250 CONFIG_SCHED_HRTICK=y CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y CONFIG_ARCH_HAS_HOLES_MEMORYMODEL=y @@ -1573,7 +1574,7 @@ CONFIG_ZRAM_WRITEBACK=y # CONFIG_BLK_DEV_COW_COMMON is not set CONFIG_BLK_DEV_LOOP=y CONFIG_BLK_DEV_LOOP_MIN_COUNT=8 -CONFIG_BLK_DEV_CRYPTOLOOP=m +CONFIG_BLK_DEV_CRYPTOLOOP=y # CONFIG_BLK_DEV_DRBD is not set CONFIG_BLK_DEV_NBD=m CONFIG_BLK_DEV_RAM=m @@ -1583,7 +1584,7 @@ CONFIG_BLK_DEV_RAM_SIZE=4096 CONFIG_ATA_OVER_ETH=m CONFIG_XEN_BLKDEV_FRONTEND=y # CONFIG_XEN_BLKDEV_BACKEND is not set -CONFIG_VIRTIO_BLK=y +CONFIG_VIRTIO_BLK=m # CONFIG_VIRTIO_BLK_SCSI is not set # CONFIG_BLK_DEV_RBD is not set # CONFIG_NVME_FC is not set @@ -1768,7 +1769,7 @@ CONFIG_BCACHE=m # CONFIG_BCACHE_DEBUG is not set # CONFIG_BCACHE_CLOSURES_DEBUG is not set CONFIG_BLK_DEV_DM_BUILTIN=y -CONFIG_BLK_DEV_DM=m +CONFIG_BLK_DEV_DM=y # CONFIG_DM_MQ_DEFAULT is not set # CONFIG_DM_DEBUG is not set CONFIG_DM_BUFIO=m @@ -5088,7 +5089,7 @@ CONFIG_RAS=y # # CONFIG_ANDROID is not set # CONFIG_LIBNVDIMM is not set -CONFIG_DAX=m +CONFIG_DAX=y # CONFIG_DEV_DAX is not set CONFIG_NVMEM=y CONFIG_MESON_EFUSE=m @@ -5326,7 +5327,7 @@ CONFIG_NFS_SWAP=y CONFIG_NFS_V4_1=y CONFIG_NFS_V4_2=y CONFIG_PNFS_FILE_LAYOUT=y -CONFIG_PNFS_BLOCK=m +CONFIG_PNFS_BLOCK=y CONFIG_PNFS_FLEXFILE_LAYOUT=m CONFIG_NFS_V4_1_IMPLEMENTATION_ID_DOMAIN="kernel.org" # CONFIG_NFS_V4_1_MIGRATION is not set diff --git a/config/kernel/linux-meson64-next.config b/config/kernel/linux-meson64-next.config index 20c50898f9..896d518710 100644 --- a/config/kernel/linux-meson64-next.config +++ b/config/kernel/linux-meson64-next.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm64 4.18.6 Kernel Configuration +# Linux/arm64 4.18.8 Kernel Configuration # # @@ -444,6 +444,7 @@ CONFIG_SCHED_MC=y CONFIG_NR_CPUS=64 CONFIG_HOTPLUG_CPU=y # CONFIG_NUMA is not set +CONFIG_HOLES_IN_ZONE=y # CONFIG_PREEMPT_NONE is not set # CONFIG_PREEMPT_VOLUNTARY is not set CONFIG_PREEMPT=y diff --git a/packages/bsp/common/usr/lib/armbian/armbian-firstrun b/packages/bsp/common/usr/lib/armbian/armbian-firstrun index 433d132230..be86dcbb08 100644 --- a/packages/bsp/common/usr/lib/armbian/armbian-firstrun +++ b/packages/bsp/common/usr/lib/armbian/armbian-firstrun @@ -96,7 +96,7 @@ case "$1" in ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf systemctl restart systemd-networkd ;; - rockchip|s5p6818|meson64|odroidc2|odroidc1) + rockchip|s5p6818|odroidc1) set_fixed_mac ;; *) diff --git a/patch/kernel/meson64-default/linux-4.14-le-amlogic-gx-1002-dts-meson-gxbb-rename_audio_card.patch b/patch/kernel/meson64-default/linux-4.14-le-amlogic-gx-1002-dts-meson-gxbb-rename_audio_card.patch new file mode 100644 index 0000000000..9480f4c720 --- /dev/null +++ b/patch/kernel/meson64-default/linux-4.14-le-amlogic-gx-1002-dts-meson-gxbb-rename_audio_card.patch @@ -0,0 +1,11 @@ +--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts 2018-05-01 01:15:01.378785083 +0200 ++++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts 2018-05-02 00:16:22.834304176 +0200 +@@ -185,7 +185,7 @@ + + sound { + compatible = "simple-audio-card"; +- simple-audio-card,name = "meson-gx-preview"; ++ simple-audio-card,name = "meson-gxbb-audio"; + status = "okay"; + + simple-audio-card,dai-link@0 { diff --git a/patch/kernel/meson64-default/linux-4.14.y-drm-fb_helper-ump-ioctls.patch b/patch/kernel/meson64-default/linux-4.14.y-drm-fb_helper-ump-ioctls.patch new file mode 100644 index 0000000000..81a727526a --- /dev/null +++ b/patch/kernel/meson64-default/linux-4.14.y-drm-fb_helper-ump-ioctls.patch @@ -0,0 +1,151 @@ +diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c +index cab14f25..cafc60ea 100644 +--- a/drivers/gpu/drm/drm_fb_helper.c ++++ b/drivers/gpu/drm/drm_fb_helper.c +@@ -1544,6 +1544,14 @@ int drm_fb_helper_ioctl(struct fb_info *info, unsigned int cmd, + + ret = 0; + goto unlock; ++#if defined(CONFIG_UMP) ++ case GET_UMP_SECURE_ID_BUF1: ++ ret = drm_get_ump_secure_id(info, fb_helper, arg, 0); ++ goto unlock; ++ case GET_UMP_SECURE_ID_BUF2: ++ ret = drm_get_ump_secure_id(info, fb_helper, arg, 1); ++ goto unlock; ++#endif + default: + ret = -ENOTTY; + } +diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile +index 8ce07039b..fdf946be3 100644 +--- a/drivers/gpu/drm/Makefile ++++ b/drivers/gpu/drm/Makefile +@@ -44,6 +44,7 @@ drm_kms_helper-$(CONFIG_DRM_DP_AUX_CHARDEV) += drm_dp_aux_dev.o + + obj-$(CONFIG_DRM_KMS_HELPER) += drm_kms_helper.o + obj-$(CONFIG_DRM_DEBUG_MM_SELFTEST) += selftests/ ++obj-$(CONFIG_UMP) += drm_fb_ump.o + + CFLAGS_drm_trace_points.o := -I$(src) + +diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h +index b069433e..95657b76 100644 +--- a/include/drm/drm_fb_helper.h ++++ b/include/drm/drm_fb_helper.h +@@ -36,6 +36,10 @@ struct drm_fb_helper; + #include + #include + ++#if defined(CONFIG_UMP) ++#include ++#endif ++ + enum mode_set_atomic { + LEAVE_ATOMIC_MODE_SET, + ENTER_ATOMIC_MODE_SET, +@@ -131,6 +135,8 @@ struct drm_fb_helper_connector { + struct drm_connector *connector; + }; + ++#define DRM_FB_UMP_COUNT 1 /* only enable one FB UMP layer */ ++ + /** + * struct drm_fb_helper - main structure to emulate fbdev on top of KMS + * @fb: Scanout framebuffer object +@@ -232,6 +238,9 @@ struct drm_fb_helper { + * See also: @deferred_setup + */ + int preferred_bpp; ++#if defined(CONFIG_UMP) ++ ump_dd_handle ump_wrapped_buffer[DRM_FB_UMP_COUNT][2]; ++#endif + }; + + /** +@@ -577,4 +586,11 @@ drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a, + #endif + } + ++#if defined(CONFIG_UMP) ++extern int (*drm_get_ump_secure_id) (struct fb_info *info, ++ struct drm_fb_helper *g_fbi, unsigned long arg, int buf); ++#define GET_UMP_SECURE_ID_BUF1 _IOWR('m', 311, unsigned int) ++#define GET_UMP_SECURE_ID_BUF2 _IOWR('m', 312, unsigned int) ++#endif ++ + #endif +--- /dev/null 2018-07-12 16:39:19.544000000 +0200 ++++ b/drivers/gpu/drm/drm_fb_ump.c 2018-07-22 22:20:45.166145058 +0200 +@@ -0,0 +1,71 @@ ++/* ++ * Copyright (C) 2016 Hardkernel Co. Ltd. ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License as ++ * published by the Free Software Foundation; either version 2 of ++ * the License, or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, ++ * MA 02111-1307 USA ++ */ ++ ++#include ++ ++#include ++#include ++#include ++#include ++#include ++ ++int (*drm_get_ump_secure_id) (struct fb_info *info, ++ struct drm_fb_helper *g_fbi, unsigned long arg, int buf); ++EXPORT_SYMBOL(drm_get_ump_secure_id); ++ ++static int _drm_get_ump_secure_id(struct fb_info *info, ++ struct drm_fb_helper *g_fbi, unsigned long arg, int buf) ++{ ++ u32 __user *psecureid = (u32 __user *) arg; ++ ump_secure_id secure_id; ++ ++ if (!g_fbi->ump_wrapped_buffer[info->node][buf]) { ++ ump_dd_physical_block ump_memory_description; ++ printk("ump: create disp: %d\n", buf); ++ ++ ump_memory_description.addr = info->fix.smem_start; ++ ump_memory_description.size = info->fix.smem_len; ++ g_fbi->ump_wrapped_buffer[info->node][buf] = ++ ump_dd_handle_create_from_phys_blocks( ++ &ump_memory_description, 1); ++ } ++ secure_id = ump_dd_secure_id_get( ++ g_fbi->ump_wrapped_buffer[info->node][buf]); ++ ++ return put_user((unsigned int)secure_id, psecureid); ++} ++ ++static int __init drm_ump_module_init(void) ++{ ++ int ret = 0; ++ drm_get_ump_secure_id = _drm_get_ump_secure_id; ++ return ret; ++} ++ ++static void __exit drm_ump_module_exit(void) ++{ ++ drm_get_ump_secure_id = NULL; ++} ++ ++module_init(drm_ump_module_init); ++module_exit(drm_ump_module_exit); ++ ++MODULE_AUTHOR("Mauro Ribeiro "); ++MODULE_DESCRIPTION("UMP Glue for DRM Framebuffer"); ++MODULE_LICENSE("GPL"); diff --git a/patch/kernel/meson64-default/linux-4.14.y-le-amlogic-gx-scpi-1003-cpufreq-scpi-avoid_failed_to_change_cpu_frequency.patch b/patch/kernel/meson64-default/linux-4.14.y-le-amlogic-gx-scpi-1003-cpufreq-scpi-avoid_failed_to_change_cpu_frequency.patch new file mode 100644 index 0000000000..9c340520ff --- /dev/null +++ b/patch/kernel/meson64-default/linux-4.14.y-le-amlogic-gx-scpi-1003-cpufreq-scpi-avoid_failed_to_change_cpu_frequency.patch @@ -0,0 +1,34 @@ +--- a/drivers/firmware/arm_scpi.c 2018-04-22 02:13:36.694055358 -0400 ++++ b/drivers/firmware/arm_scpi.c 2018-04-22 19:27:58.671389066 -0400 +@@ -88,7 +88,8 @@ + #define FW_REV_MINOR(x) (((x) & FW_REV_MINOR_MASK) >> FW_REV_MINOR_BITS) + #define FW_REV_PATCH(x) ((x) & FW_REV_PATCH_MASK) + +-#define MAX_RX_TIMEOUT (msecs_to_jiffies(30)) ++#define MAX_TX_TIMEOUT 60 ++#define MAX_RX_TIMEOUT (msecs_to_jiffies(90)) + + enum scpi_error_codes { + SCPI_SUCCESS = 0, /* Success */ +@@ -523,6 +524,12 @@ + chan = atomic_inc_return(&scpi_info->next_chan) % + scpi_info->num_chans; + scpi_chan = scpi_info->channels + chan; ++ scpi_chan->cl.tx_tout = MAX_TX_TIMEOUT; ++ ++ if ((idx == CMD_GET_DVFS) || (idx == CMD_SET_DVFS)) ++ scpi_chan->cl.tx_tout = 400; ++ else if (idx == CMD_SENSOR_VALUE) ++ scpi_chan->cl.tx_tout = 100; + + msg = get_scpi_xfer(scpi_chan); + if (!msg) +@@ -999,7 +1006,7 @@ + cl->rx_callback = scpi_handle_remote_msg; + cl->tx_prepare = scpi_tx_prepare; + cl->tx_block = true; +- cl->tx_tout = 20; ++ cl->tx_tout = MAX_TX_TIMEOUT; + cl->knows_txdone = false; /* controller can't ack */ + + INIT_LIST_HEAD(&pchan->rx_pending); diff --git a/patch/kernel/meson64-default/linux-4.14.y-le-amlogic-gx-scpi-1004-mailbox-revert_switch_to_hrtimer_for_tx_complete_polling.patch b/patch/kernel/meson64-default/linux-4.14.y-le-amlogic-gx-scpi-1004-mailbox-revert_switch_to_hrtimer_for_tx_complete_polling.patch new file mode 100644 index 0000000000..2dd8b1c9cd --- /dev/null +++ b/patch/kernel/meson64-default/linux-4.14.y-le-amlogic-gx-scpi-1004-mailbox-revert_switch_to_hrtimer_for_tx_complete_polling.patch @@ -0,0 +1,103 @@ +diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c +index 674b35f40..3497cabda 100644 +--- a/drivers/mailbox/mailbox.c ++++ b/drivers/mailbox/mailbox.c +@@ -26,6 +26,8 @@ + static LIST_HEAD(mbox_cons); + static DEFINE_MUTEX(con_mutex); + ++static void poll_txdone(struct timer_list *t); ++ + static int add_to_rbuf(struct mbox_chan *chan, void *mssg) + { + int idx; +@@ -86,8 +88,7 @@ static void msg_submit(struct mbox_chan *chan) + spin_unlock_irqrestore(&chan->lock, flags); + + if (!err && (chan->txdone_method & TXDONE_BY_POLL)) +- /* kick start the timer immediately to avoid delays */ +- hrtimer_start(&chan->mbox->poll_hrt, 0, HRTIMER_MODE_REL); ++ poll_txdone(&chan->mbox->poll); + } + + static void tx_tick(struct mbox_chan *chan, int r) +@@ -114,10 +115,9 @@ static void tx_tick(struct mbox_chan *chan, int r) + complete(&chan->tx_complete); + } + +-static enum hrtimer_restart txdone_hrtimer(struct hrtimer *hrtimer) ++static void poll_txdone(struct timer_list *t) + { +- struct mbox_controller *mbox = +- container_of(hrtimer, struct mbox_controller, poll_hrt); ++ struct mbox_controller *mbox = from_timer(mbox, t, poll); + bool txdone, resched = false; + int i; + +@@ -133,11 +133,9 @@ static enum hrtimer_restart txdone_hrtimer(struct hrtimer *hrtimer) + } + } + +- if (resched) { +- hrtimer_forward_now(hrtimer, ms_to_ktime(mbox->txpoll_period)); +- return HRTIMER_RESTART; +- } +- return HRTIMER_NORESTART; ++ if (resched) ++ mod_timer(&mbox->poll, jiffies + ++ msecs_to_jiffies(mbox->txpoll_period)); + } + + /** +@@ -466,9 +464,7 @@ int mbox_controller_register(struct mbox_controller *mbox) + return -EINVAL; + } + +- hrtimer_init(&mbox->poll_hrt, CLOCK_MONOTONIC, +- HRTIMER_MODE_REL); +- mbox->poll_hrt.function = txdone_hrtimer; ++ timer_setup(&mbox->poll, &poll_txdone, 0); + } + + for (i = 0; i < mbox->num_chans; i++) { +@@ -510,7 +506,7 @@ void mbox_controller_unregister(struct mbox_controller *mbox) + mbox_free_channel(&mbox->chans[i]); + + if (mbox->txdone_poll) +- hrtimer_cancel(&mbox->poll_hrt); ++ del_timer_sync(&mbox->poll); + + mutex_unlock(&con_mutex); + } +diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h +index 74deadb42..68c424544 100644 +--- a/include/linux/mailbox_controller.h ++++ b/include/linux/mailbox_controller.h +@@ -9,7 +9,7 @@ + + #include + #include +-#include ++#include + #include + #include + +@@ -67,8 +67,7 @@ struct mbox_chan_ops { + * @txpoll_period: If 'txdone_poll' is in effect, the API polls for + * last TX's status after these many millisecs + * @of_xlate: Controller driver specific mapping of channel via DT +- * @poll_hrt: API private. hrtimer used to poll for TXDONE on all +- * channels. ++ * @poll: API private. Used to poll for TXDONE on all channels. + * @node: API private. To hook into list of controllers. + */ + struct mbox_controller { +@@ -82,7 +81,7 @@ struct mbox_controller { + struct mbox_chan *(*of_xlate)(struct mbox_controller *mbox, + const struct of_phandle_args *sp); + /* Internal to API */ +- struct hrtimer poll_hrt; ++ struct timer_list poll; + struct list_head node; + }; + diff --git a/patch/kernel/meson64-default/linux-4.14.y-le-amlogic-gx-scpi-2000-cpufreq-scpi-scpi_send_message-debug.patch b/patch/kernel/meson64-default/linux-4.14.y-le-amlogic-gx-scpi-2000-cpufreq-scpi-scpi_send_message-debug.patch new file mode 100644 index 0000000000..b0a99a0daa --- /dev/null +++ b/patch/kernel/meson64-default/linux-4.14.y-le-amlogic-gx-scpi-2000-cpufreq-scpi-scpi_send_message-debug.patch @@ -0,0 +1,24 @@ +--- a/drivers/firmware/arm_scpi.c 2018-04-28 00:27:06.193482672 +0200 ++++ b/drivers/firmware/arm_scpi.c 2018-04-28 01:10:20.073047893 +0200 +@@ -555,6 +555,12 @@ + scpi_process_cmd(scpi_chan, msg->cmd); + + put_scpi_xfer(msg, scpi_chan); ++ ++ if ((ret == -ETIME) || (ret == -ETIMEDOUT)) { ++ pr_err("%s: mbox_send_message %hhu via channel%hhu failed: %d\n", __func__, ++ idx, chan, ret); ++ } ++ + /* SCPI error codes > 0, translate them to Linux scale*/ + return ret > 0 ? scpi_to_linux_errno(ret) : ret; + } +@@ -979,6 +985,8 @@ + struct mbox_client *cl = &pchan->cl; + struct device_node *shmem = of_parse_phandle(np, "shmem", idx); + ++ _dev_info(dev, "get channel%d", idx); ++ + ret = of_address_to_resource(shmem, 0, &res); + of_node_put(shmem); + if (ret) { diff --git a/patch/kernel/meson64-default/stmmac_platform_mac_addr_set.patch b/patch/kernel/meson64-default/stmmac_platform_mac_addr_set.patch new file mode 100644 index 0000000000..218fcc71ee --- /dev/null +++ b/patch/kernel/meson64-default/stmmac_platform_mac_addr_set.patch @@ -0,0 +1,60 @@ +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c 2017-11-24 08:33:43.000000000 +0100 ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c 2017-12-28 19:40:51.443864071 +0100 +@@ -33,6 +33,41 @@ + #include "stmmac.h" + #include "stmmac_platform.h" + ++#ifdef CONFIG_DWMAC_MESON ++static u8 DEFMAC[] = {0, 0, 0, 0, 0, 0}; ++static unsigned int g_mac_addr_setup; ++static unsigned char chartonum(char c) ++{ ++ if (c >= '0' && c <= '9') ++ return c - '0'; ++ if (c >= 'A' && c <= 'F') ++ return (c - 'A') + 10; ++ if (c >= 'a' && c <= 'f') ++ return (c - 'a') + 10; ++ return 0; ++ ++} ++ ++static int __init mac_addr_set(char *line) ++{ ++ unsigned char mac[6]; ++ int i = 0; ++ for (i = 0; i < 6 && line[0] != '\0' && line[1] != '\0'; i++) { ++ mac[i] = chartonum(line[0]) << 4 | chartonum(line[1]); ++ line += 3; ++ } ++ memcpy(DEFMAC, mac, 6); ++ pr_debug("uboot setup mac-addr: %x:%x:%x:%x:%x:%x\n", ++ DEFMAC[0], DEFMAC[1], DEFMAC[2], DEFMAC[3], DEFMAC[4], ++ DEFMAC[5]); ++ g_mac_addr_setup++; ++ ++ return 1; ++} ++ ++__setup("mac=", mac_addr_set); ++#endif ++ + #ifdef CONFIG_OF + + /** +@@ -218,7 +253,15 @@ + if (!plat) + return ERR_PTR(-ENOMEM); + ++#ifdef CONFIG_DWMAC_MESON ++ if (g_mac_addr_setup) /*so uboot mac= is first priority.*/ ++ *mac = DEFMAC; ++ else ++ *mac = of_get_mac_address(np); ++#else + *mac = of_get_mac_address(np); ++#endif ++ + plat->interface = of_get_phy_mode(np); + + /* Get max speed of operation from device tree */ diff --git a/patch/kernel/meson64-next/stmmac_platform_mac_addr_set.patch b/patch/kernel/meson64-next/stmmac_platform_mac_addr_set.patch new file mode 100644 index 0000000000..218fcc71ee --- /dev/null +++ b/patch/kernel/meson64-next/stmmac_platform_mac_addr_set.patch @@ -0,0 +1,60 @@ +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c 2017-11-24 08:33:43.000000000 +0100 ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c 2017-12-28 19:40:51.443864071 +0100 +@@ -33,6 +33,41 @@ + #include "stmmac.h" + #include "stmmac_platform.h" + ++#ifdef CONFIG_DWMAC_MESON ++static u8 DEFMAC[] = {0, 0, 0, 0, 0, 0}; ++static unsigned int g_mac_addr_setup; ++static unsigned char chartonum(char c) ++{ ++ if (c >= '0' && c <= '9') ++ return c - '0'; ++ if (c >= 'A' && c <= 'F') ++ return (c - 'A') + 10; ++ if (c >= 'a' && c <= 'f') ++ return (c - 'a') + 10; ++ return 0; ++ ++} ++ ++static int __init mac_addr_set(char *line) ++{ ++ unsigned char mac[6]; ++ int i = 0; ++ for (i = 0; i < 6 && line[0] != '\0' && line[1] != '\0'; i++) { ++ mac[i] = chartonum(line[0]) << 4 | chartonum(line[1]); ++ line += 3; ++ } ++ memcpy(DEFMAC, mac, 6); ++ pr_debug("uboot setup mac-addr: %x:%x:%x:%x:%x:%x\n", ++ DEFMAC[0], DEFMAC[1], DEFMAC[2], DEFMAC[3], DEFMAC[4], ++ DEFMAC[5]); ++ g_mac_addr_setup++; ++ ++ return 1; ++} ++ ++__setup("mac=", mac_addr_set); ++#endif ++ + #ifdef CONFIG_OF + + /** +@@ -218,7 +253,15 @@ + if (!plat) + return ERR_PTR(-ENOMEM); + ++#ifdef CONFIG_DWMAC_MESON ++ if (g_mac_addr_setup) /*so uboot mac= is first priority.*/ ++ *mac = DEFMAC; ++ else ++ *mac = of_get_mac_address(np); ++#else + *mac = of_get_mac_address(np); ++#endif ++ + plat->interface = of_get_phy_mode(np); + + /* Get max speed of operation from device tree */