Linux Audio

Check our new training course

Buildroot integration, development and maintenance

Need a Buildroot system for your embedded project?
Loading...
v4.17
  1/*
  2 * Code commons to all DaVinci SoCs.
  3 *
  4 * Author: Mark A. Greer <mgreer@mvista.com>
  5 *
  6 * 2009 (c) MontaVista Software, Inc. This file is licensed under
  7 * the terms of the GNU General Public License version 2. This program
  8 * is licensed "as is" without any warranty of any kind, whether express
  9 * or implied.
 10 */
 11#include <linux/module.h>
 12#include <linux/io.h>
 13#include <linux/etherdevice.h>
 14#include <linux/davinci_emac.h>
 15#include <linux/dma-mapping.h>
 16
 17#include <asm/tlb.h>
 18#include <asm/mach/map.h>
 19
 20#include <mach/common.h>
 21#include <mach/cputype.h>
 22
 23#include "clock.h"
 24
 25struct davinci_soc_info davinci_soc_info;
 26EXPORT_SYMBOL(davinci_soc_info);
 27
 28void __iomem *davinci_intc_base;
 29int davinci_intc_type;
 30
 31void davinci_get_mac_addr(struct nvmem_device *nvmem, void *context)
 32{
 33	char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
 34	off_t offset = (off_t)context;
 35
 36	if (!IS_BUILTIN(CONFIG_NVMEM)) {
 37		pr_warn("Cannot read MAC addr from EEPROM without CONFIG_NVMEM\n");
 38		return;
 39	}
 40
 41	/* Read MAC addr from EEPROM */
 42	if (nvmem_device_read(nvmem, offset, ETH_ALEN, mac_addr) == ETH_ALEN)
 43		pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
 44}
 45
 46static int __init davinci_init_id(struct davinci_soc_info *soc_info)
 47{
 48	int			i;
 49	struct davinci_id	*dip;
 50	u8			variant;
 51	u16			part_no;
 52	void __iomem		*base;
 53
 54	base = ioremap(soc_info->jtag_id_reg, SZ_4K);
 55	if (!base) {
 56		pr_err("Unable to map JTAG ID register\n");
 57		return -ENOMEM;
 58	}
 59
 60	soc_info->jtag_id = __raw_readl(base);
 61	iounmap(base);
 62
 63	variant = (soc_info->jtag_id & 0xf0000000) >> 28;
 64	part_no = (soc_info->jtag_id & 0x0ffff000) >> 12;
 65
 66	for (i = 0, dip = soc_info->ids; i < soc_info->ids_num;
 67			i++, dip++)
 68		/* Don't care about the manufacturer right now */
 69		if ((dip->part_no == part_no) && (dip->variant == variant)) {
 70			soc_info->cpu_id = dip->cpu_id;
 71			pr_info("DaVinci %s variant 0x%x\n", dip->name,
 72					dip->variant);
 73			return 0;
 74		}
 75
 76	pr_err("Unknown DaVinci JTAG ID 0x%x\n", soc_info->jtag_id);
 77	return -EINVAL;
 78}
 79
 80void __init davinci_common_init(const struct davinci_soc_info *soc_info)
 81{
 82	int ret;
 83
 84	if (!soc_info) {
 85		ret = -EINVAL;
 86		goto err;
 87	}
 88
 89	memcpy(&davinci_soc_info, soc_info, sizeof(struct davinci_soc_info));
 90
 91	if (davinci_soc_info.io_desc && (davinci_soc_info.io_desc_num > 0))
 92		iotable_init(davinci_soc_info.io_desc,
 93				davinci_soc_info.io_desc_num);
 94
 95	/*
 96	 * Normally devicemaps_init() would flush caches and tlb after
 97	 * mdesc->map_io(), but we must also do it here because of the CPU
 98	 * revision check below.
 99	 */
100	local_flush_tlb_all();
101	flush_cache_all();
102
103	/*
104	 * We want to check CPU revision early for cpu_is_xxxx() macros.
105	 * IO space mapping must be initialized before we can do that.
106	 */
107	ret = davinci_init_id(&davinci_soc_info);
108	if (ret < 0)
109		goto err;
110
 
 
 
 
 
 
111
112	return;
113
114err:
115	panic("davinci_common_init: SoC Initialization failed\n");
116}
117
118void __init davinci_init_late(void)
119{
120	davinci_cpufreq_init();
 
121	davinci_clk_disable_unused();
122}
v3.15
  1/*
  2 * Code commons to all DaVinci SoCs.
  3 *
  4 * Author: Mark A. Greer <mgreer@mvista.com>
  5 *
  6 * 2009 (c) MontaVista Software, Inc. This file is licensed under
  7 * the terms of the GNU General Public License version 2. This program
  8 * is licensed "as is" without any warranty of any kind, whether express
  9 * or implied.
 10 */
 11#include <linux/module.h>
 12#include <linux/io.h>
 13#include <linux/etherdevice.h>
 14#include <linux/davinci_emac.h>
 15#include <linux/dma-mapping.h>
 16
 17#include <asm/tlb.h>
 18#include <asm/mach/map.h>
 19
 20#include <mach/common.h>
 21#include <mach/cputype.h>
 22
 23#include "clock.h"
 24
 25struct davinci_soc_info davinci_soc_info;
 26EXPORT_SYMBOL(davinci_soc_info);
 27
 28void __iomem *davinci_intc_base;
 29int davinci_intc_type;
 30
 31void davinci_get_mac_addr(struct memory_accessor *mem_acc, void *context)
 32{
 33	char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
 34	off_t offset = (off_t)context;
 35
 
 
 
 
 
 36	/* Read MAC addr from EEPROM */
 37	if (mem_acc->read(mem_acc, mac_addr, offset, ETH_ALEN) == ETH_ALEN)
 38		pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
 39}
 40
 41static int __init davinci_init_id(struct davinci_soc_info *soc_info)
 42{
 43	int			i;
 44	struct davinci_id	*dip;
 45	u8			variant;
 46	u16			part_no;
 47	void __iomem		*base;
 48
 49	base = ioremap(soc_info->jtag_id_reg, SZ_4K);
 50	if (!base) {
 51		pr_err("Unable to map JTAG ID register\n");
 52		return -ENOMEM;
 53	}
 54
 55	soc_info->jtag_id = __raw_readl(base);
 56	iounmap(base);
 57
 58	variant = (soc_info->jtag_id & 0xf0000000) >> 28;
 59	part_no = (soc_info->jtag_id & 0x0ffff000) >> 12;
 60
 61	for (i = 0, dip = soc_info->ids; i < soc_info->ids_num;
 62			i++, dip++)
 63		/* Don't care about the manufacturer right now */
 64		if ((dip->part_no == part_no) && (dip->variant == variant)) {
 65			soc_info->cpu_id = dip->cpu_id;
 66			pr_info("DaVinci %s variant 0x%x\n", dip->name,
 67					dip->variant);
 68			return 0;
 69		}
 70
 71	pr_err("Unknown DaVinci JTAG ID 0x%x\n", soc_info->jtag_id);
 72	return -EINVAL;
 73}
 74
 75void __init davinci_common_init(struct davinci_soc_info *soc_info)
 76{
 77	int ret;
 78
 79	if (!soc_info) {
 80		ret = -EINVAL;
 81		goto err;
 82	}
 83
 84	memcpy(&davinci_soc_info, soc_info, sizeof(struct davinci_soc_info));
 85
 86	if (davinci_soc_info.io_desc && (davinci_soc_info.io_desc_num > 0))
 87		iotable_init(davinci_soc_info.io_desc,
 88				davinci_soc_info.io_desc_num);
 89
 90	/*
 91	 * Normally devicemaps_init() would flush caches and tlb after
 92	 * mdesc->map_io(), but we must also do it here because of the CPU
 93	 * revision check below.
 94	 */
 95	local_flush_tlb_all();
 96	flush_cache_all();
 97
 98	/*
 99	 * We want to check CPU revision early for cpu_is_xxxx() macros.
100	 * IO space mapping must be initialized before we can do that.
101	 */
102	ret = davinci_init_id(&davinci_soc_info);
103	if (ret < 0)
104		goto err;
105
106	if (davinci_soc_info.cpu_clks) {
107		ret = davinci_clk_init(davinci_soc_info.cpu_clks);
108
109		if (ret != 0)
110			goto err;
111	}
112
113	return;
114
115err:
116	panic("davinci_common_init: SoC Initialization failed\n");
117}
118
119void __init davinci_init_late(void)
120{
121	davinci_cpufreq_init();
122	davinci_pm_init();
123	davinci_clk_disable_unused();
124}