Linux Audio

Check our new training course

Loading...
v6.8
  1// SPDX-License-Identifier: GPL-2.0-only
  2/*
  3 * Joshua Henderson, joshua.henderson@microchip.com
  4 * Copyright (C) 2015 Microchip Technology Inc.  All rights reserved.
 
 
 
 
 
 
 
 
 
  5 */
  6#include <linux/init.h>
  7#include <linux/kernel.h>
  8#include <linux/of_address.h>
  9#include <linux/of_fdt.h>
 10#include <linux/of_platform.h>
 11#include <linux/platform_data/sdhci-pic32.h>
 12
 13#include <asm/fw/fw.h>
 14#include <asm/mips-boards/generic.h>
 15#include <asm/prom.h>
 16
 17#include "pic32mzda.h"
 18
 19const char *get_system_type(void)
 20{
 21	return "PIC32MZDA";
 22}
 23
 
 
 
 
 
 
 
 
 
 
 
 
 
 24void __init plat_mem_setup(void)
 25{
 26	void *dtb;
 27
 28	dtb = get_fdt();
 29	if (!dtb) {
 30		pr_err("pic32: no DTB found.\n");
 31		return;
 32	}
 33
 34	/*
 35	 * Load the builtin device tree. This causes the chosen node to be
 36	 * parsed resulting in our memory appearing.
 37	 */
 38	__dt_setup_arch(dtb);
 39
 40	pr_info("Found following command lines\n");
 41	pr_info(" boot_command_line: %s\n", boot_command_line);
 42	pr_info(" arcs_cmdline     : %s\n", arcs_cmdline);
 43#ifdef CONFIG_CMDLINE_BOOL
 44	pr_info(" builtin_cmdline  : %s\n", CONFIG_CMDLINE);
 45#endif
 46	if (dtb != __dtb_start)
 47		strscpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
 48
 49#ifdef CONFIG_EARLY_PRINTK
 50	fw_init_early_console();
 51#endif
 52	pic32_config_init();
 53}
 54
 55static __init void pic32_init_cmdline(int argc, char *argv[])
 56{
 57	unsigned int count = COMMAND_LINE_SIZE - 1;
 58	int i;
 59	char *dst = &(arcs_cmdline[0]);
 60	char *src;
 61
 62	for (i = 1; i < argc && count; ++i) {
 63		src = argv[i];
 64		while (*src && count) {
 65			*dst++ = *src++;
 66			--count;
 67		}
 68		*dst++ = ' ';
 69	}
 70	if (i > 1)
 71		--dst;
 72
 73	*dst = 0;
 74}
 75
 76void __init prom_init(void)
 77{
 78	pic32_init_cmdline((int)fw_arg0, (char **)fw_arg1);
 79}
 80
 
 
 
 
 
 
 
 
 
 
 
 
 81static struct pic32_sdhci_platform_data sdhci_data = {
 82	.setup_dma = pic32_set_sdhci_adma_fifo_threshold,
 83};
 84
 85static struct of_dev_auxdata pic32_auxdata_lookup[] __initdata = {
 86	OF_DEV_AUXDATA("microchip,pic32mzda-sdhci", 0, "sdhci", &sdhci_data),
 87	{ /* sentinel */}
 88};
 89
 90static int __init pic32_of_prepare_platform_data(struct of_dev_auxdata *lookup)
 91{
 92	struct device_node *root, *np;
 93	struct resource res;
 94
 95	root = of_find_node_by_path("/");
 96
 97	for (; lookup->compatible; lookup++) {
 98		np = of_find_compatible_node(NULL, NULL, lookup->compatible);
 99		if (np) {
100			lookup->name = (char *)np->name;
101			if (lookup->phys_addr) {
102				of_node_put(np);
103				continue;
104			}
105			if (!of_address_to_resource(np, 0, &res))
106				lookup->phys_addr = res.start;
107			of_node_put(np);
108		}
109	}
110
111	of_node_put(root);
112
113	return 0;
114}
115
116static int __init plat_of_setup(void)
117{
118	if (!of_have_populated_dt())
119		panic("Device tree not present");
120
121	pic32_of_prepare_platform_data(pic32_auxdata_lookup);
122	if (of_platform_default_populate(NULL, pic32_auxdata_lookup, NULL))
123		panic("Failed to populate DT");
124
125	return 0;
126}
127arch_initcall(plat_of_setup);
v4.10.11
 
  1/*
  2 * Joshua Henderson, joshua.henderson@microchip.com
  3 * Copyright (C) 2015 Microchip Technology Inc.  All rights reserved.
  4 *
  5 *  This program is free software; you can distribute it and/or modify it
  6 *  under the terms of the GNU General Public License (Version 2) as
  7 *  published by the Free Software Foundation.
  8 *
  9 *  This program is distributed in the hope it will be useful, but WITHOUT
 10 *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11 *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12 *  for more details.
 13 */
 14#include <linux/init.h>
 15#include <linux/kernel.h>
 16#include <linux/of_address.h>
 17#include <linux/of_fdt.h>
 18#include <linux/of_platform.h>
 19#include <linux/platform_data/sdhci-pic32.h>
 20
 21#include <asm/fw/fw.h>
 22#include <asm/mips-boards/generic.h>
 23#include <asm/prom.h>
 24
 25#include "pic32mzda.h"
 26
 27const char *get_system_type(void)
 28{
 29	return "PIC32MZDA";
 30}
 31
 32static ulong get_fdtaddr(void)
 33{
 34	ulong ftaddr = 0;
 35
 36	if (fw_passed_dtb && !fw_arg2 && !fw_arg3)
 37		return (ulong)fw_passed_dtb;
 38
 39	if (__dtb_start < __dtb_end)
 40		ftaddr = (ulong)__dtb_start;
 41
 42	return ftaddr;
 43}
 44
 45void __init plat_mem_setup(void)
 46{
 47	void *dtb;
 48
 49	dtb = (void *)get_fdtaddr();
 50	if (!dtb) {
 51		pr_err("pic32: no DTB found.\n");
 52		return;
 53	}
 54
 55	/*
 56	 * Load the builtin device tree. This causes the chosen node to be
 57	 * parsed resulting in our memory appearing.
 58	 */
 59	__dt_setup_arch(dtb);
 60
 61	pr_info("Found following command lines\n");
 62	pr_info(" boot_command_line: %s\n", boot_command_line);
 63	pr_info(" arcs_cmdline     : %s\n", arcs_cmdline);
 64#ifdef CONFIG_CMDLINE_BOOL
 65	pr_info(" builtin_cmdline  : %s\n", CONFIG_CMDLINE);
 66#endif
 67	if (dtb != __dtb_start)
 68		strlcpy(arcs_cmdline, boot_command_line, COMMAND_LINE_SIZE);
 69
 70#ifdef CONFIG_EARLY_PRINTK
 71	fw_init_early_console(-1);
 72#endif
 73	pic32_config_init();
 74}
 75
 76static __init void pic32_init_cmdline(int argc, char *argv[])
 77{
 78	unsigned int count = COMMAND_LINE_SIZE - 1;
 79	int i;
 80	char *dst = &(arcs_cmdline[0]);
 81	char *src;
 82
 83	for (i = 1; i < argc && count; ++i) {
 84		src = argv[i];
 85		while (*src && count) {
 86			*dst++ = *src++;
 87			--count;
 88		}
 89		*dst++ = ' ';
 90	}
 91	if (i > 1)
 92		--dst;
 93
 94	*dst = 0;
 95}
 96
 97void __init prom_init(void)
 98{
 99	pic32_init_cmdline((int)fw_arg0, (char **)fw_arg1);
100}
101
102void __init prom_free_prom_memory(void)
103{
104}
105
106void __init device_tree_init(void)
107{
108	if (!initial_boot_params)
109		return;
110
111	unflatten_and_copy_device_tree();
112}
113
114static struct pic32_sdhci_platform_data sdhci_data = {
115	.setup_dma = pic32_set_sdhci_adma_fifo_threshold,
116};
117
118static struct of_dev_auxdata pic32_auxdata_lookup[] __initdata = {
119	OF_DEV_AUXDATA("microchip,pic32mzda-sdhci", 0, "sdhci", &sdhci_data),
120	{ /* sentinel */}
121};
122
123static int __init pic32_of_prepare_platform_data(struct of_dev_auxdata *lookup)
124{
125	struct device_node *root, *np;
126	struct resource res;
127
128	root = of_find_node_by_path("/");
129
130	for (; lookup->compatible; lookup++) {
131		np = of_find_compatible_node(NULL, NULL, lookup->compatible);
132		if (np) {
133			lookup->name = (char *)np->name;
134			if (lookup->phys_addr)
 
135				continue;
 
136			if (!of_address_to_resource(np, 0, &res))
137				lookup->phys_addr = res.start;
 
138		}
139	}
 
 
140
141	return 0;
142}
143
144static int __init plat_of_setup(void)
145{
146	if (!of_have_populated_dt())
147		panic("Device tree not present");
148
149	pic32_of_prepare_platform_data(pic32_auxdata_lookup);
150	if (of_platform_default_populate(NULL, pic32_auxdata_lookup, NULL))
151		panic("Failed to populate DT");
152
153	return 0;
154}
155arch_initcall(plat_of_setup);