9
0
Fork 0

ARM am33xx: Add cpws convenience functions

This adds a function to register the cpws device and another one
to register the MAC addresses provided by the am33xx.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2013-01-09 11:39:56 +01:00
parent 5824325936
commit cee6e122ff
3 changed files with 40 additions and 0 deletions

View File

@ -18,11 +18,14 @@
* MA 02111-1307 USA
*/
#include <common.h>
#include <io.h>
#include <net.h>
#include <mach/am33xx-silicon.h>
#include <mach/am33xx-clock.h>
#include <mach/sys_info.h>
#include <mach/xload.h>
#include <mach/am33xx-generic.h>
void __noreturn reset_cpu(unsigned long addr)
{
@ -95,3 +98,27 @@ enum omap_boot_src am33xx_bootsrc(void)
{
return OMAP_BOOTSRC_MMC1; /* only MMC for now */
}
int am33xx_register_ethaddr(int eth_id, int mac_id)
{
void __iomem *mac_id_low = (void *)AM33XX_MAC_ID0_LO + mac_id * 8;
void __iomem *mac_id_high = (void *)AM33XX_MAC_ID0_HI + mac_id * 8;
uint8_t mac_addr[6];
uint32_t mac_hi, mac_lo;
mac_lo = readl(mac_id_low);
mac_hi = readl(mac_id_high);
mac_addr[0] = mac_hi & 0xff;
mac_addr[1] = (mac_hi & 0xff00) >> 8;
mac_addr[2] = (mac_hi & 0xff0000) >> 16;
mac_addr[3] = (mac_hi & 0xff000000) >> 24;
mac_addr[4] = mac_lo & 0xff;
mac_addr[5] = (mac_lo & 0xff00) >> 8;
if (is_valid_ether_addr(mac_addr)) {
eth_register_ethaddr(eth_id, mac_addr);
return 0;
}
return -ENODEV;
}

View File

@ -6,6 +6,7 @@
#include <mach/am33xx-silicon.h>
#include <mach/devices.h>
#include <mach/omap_hsmmc.h>
#include <mach/cpsw.h>
/* the device numbering is the same as in the TRM memory map (SPRUH73G) */
@ -30,4 +31,10 @@ static inline struct device_d *am33xx_add_mmc0(struct omap_hsmmc_platform_data *
AM33XX_MMCHS0_BASE, SZ_4K, IORESOURCE_MEM, pdata);
}
static inline struct device_d *am33xx_add_cpsw(struct cpsw_platform_data *cpsw_data)
{
return add_generic_device("cpsw", 0, NULL,
AM335X_CPSW_BASE, SZ_32K, IORESOURCE_MEM, cpsw_data);
}
#endif /* __MACH_OMAP3_DEVICES_H */

View File

@ -0,0 +1,6 @@
#ifndef __MACH_AM33XX_GENERIC_H
#define __MACH_AM33XX_GENERIC_H
int am33xx_register_ethaddr(int eth_id, int mac_id);
#endif /* __MACH_AM33XX_GENERIC_H */