blob: 97b3f82444d97876ed5d6e65572378f3d0ce2836 [file] [log] [blame]
Gregory CLEMENTaf05ee52018-12-14 16:16:47 +01001/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */
2/*
3 * Copyright (c) 2018 Microsemi Corporation
4 */
5
6#ifndef __ASM_MACH_COMMON_H
7#define __ASM_MACH_COMMON_H
8
9#if defined(CONFIG_SOC_OCELOT)
10#include <mach/ocelot/ocelot.h>
11#include <mach/ocelot/ocelot_devcpu_gcb.h>
Lars Povlsen0ee16642018-12-20 09:56:02 +010012#include <mach/ocelot/ocelot_devcpu_gcb_miim_regs.h>
Gregory CLEMENTaf05ee52018-12-14 16:16:47 +010013#include <mach/ocelot/ocelot_icpu_cfg.h>
Gregory CLEMENT819b57212018-12-14 16:16:48 +010014#elif defined(CONFIG_SOC_LUTON)
15#include <mach/luton/luton.h>
16#include <mach/luton/luton_devcpu_gcb.h>
Lars Povlsen0ee16642018-12-20 09:56:02 +010017#include <mach/luton/luton_devcpu_gcb_miim_regs.h>
Gregory CLEMENT819b57212018-12-14 16:16:48 +010018#include <mach/luton/luton_icpu_cfg.h>
Horatiu Vultur8a22b882019-01-12 18:56:56 +010019#elif defined(CONFIG_SOC_JR2)
20#include <mach/jr2/jr2.h>
21#include <mach/jr2/jr2_devcpu_gcb.h>
22#include <mach/jr2/jr2_devcpu_gcb_miim_regs.h>
23#include <mach/jr2/jr2_icpu_cfg.h>
Horatiu Vulturc15620a2019-01-17 15:33:27 +010024#elif defined(CONFIG_SOC_SERVALT)
25#include <mach/servalt/servalt.h>
26#include <mach/servalt/servalt_devcpu_gcb.h>
27#include <mach/servalt/servalt_devcpu_gcb_miim_regs.h>
28#include <mach/servalt/servalt_icpu_cfg.h>
Gregory CLEMENTaf05ee52018-12-14 16:16:47 +010029#else
30#error Unsupported platform
31#endif
32
33#define MSCC_DDR_TO 0x20000000 /* DDR RAM base offset */
34#define MSCC_MEMCTL1_TO 0x40000000 /* SPI/PI base offset */
35#define MSCC_MEMCTL2_TO 0x50000000 /* SPI/PI base offset */
36#define MSCC_FLASH_TO MSCC_MEMCTL1_TO /* Flash base offset */
37
38#define VCOREIII_TIMER_DIVIDER 25 /* Clock tick ~ 0.1 us */
39
Lars Povlsen0ee16642018-12-20 09:56:02 +010040/* Common utility functions */
41
Lars Povlsenf01b7322019-01-08 10:38:33 +010042/*
43 * Perform a number of NOP instructions, blocks of 8 instructions.
44 * The (inlined) function will not affect cache or processor state.
45 */
46static inline void mscc_vcoreiii_nop_delay(int delay)
47{
48 while (delay > 0) {
49#define DELAY_8_NOPS() asm volatile("nop; nop; nop; nop; nop; nop; nop; nop;")
50 switch (delay) {
51 case 8:
52 DELAY_8_NOPS();
53 /* fallthrough */
54 case 7:
55 DELAY_8_NOPS();
56 /* fallthrough */
57 case 6:
58 DELAY_8_NOPS();
59 /* fallthrough */
60 case 5:
61 DELAY_8_NOPS();
62 /* fallthrough */
63 case 4:
64 DELAY_8_NOPS();
65 /* fallthrough */
66 case 3:
67 DELAY_8_NOPS();
68 /* fallthrough */
69 case 2:
70 DELAY_8_NOPS();
71 /* fallthrough */
72 case 1:
73 DELAY_8_NOPS();
74 }
75 delay -= 8;
76#undef DELAY_8_NOPS
77 }
78}
79
Lars Povlsen0ee16642018-12-20 09:56:02 +010080int mscc_phy_rd_wr(u8 read,
81 u32 miim_controller,
82 u8 miim_addr,
83 u8 addr,
84 u16 *value);
85
86int mscc_phy_rd(u32 miim_controller,
87 u8 miim_addr,
88 u8 addr,
89 u16 *value);
90
91int mscc_phy_wr(u32 miim_controller,
92 u8 miim_addr,
93 u8 addr,
94 u16 value);
95
Lars Povlsen585078f2018-12-20 09:56:03 +010096void mscc_gpio_set_alternate(int gpio, int mode);
97
Gregory CLEMENTaf05ee52018-12-14 16:16:47 +010098#endif /* __ASM_MACH_COMMON_H */