summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-12-03 16:17:43 +0000
committerAidan MacDonald <amachronic@protonmail.com>2022-12-31 08:10:41 -0500
commit484a79fcc0bb762acc1c3a502b237a68588ab4ab (patch)
treeb27aac3480ee800bd9690c7637c53af03310961a
parenta980d5f86951dca03baa447fd5a58005ba47a098 (diff)
downloadrockbox-484a79fcc0bb762acc1c3a502b237a68588ab4ab.tar.gz
rockbox-484a79fcc0bb762acc1c3a502b237a68588ab4ab.zip
x1000: Add INIT_ATTR to various target specific functions
Add INIT_ATTR to some low-hanging fruit in the X1000 code: GPIO init, GPIO initial state tables, clock init, and DMA init. Change-Id: Ia02b20945da1bbed103e2e01eaf60553eb5f72d4
-rw-r--r--firmware/target/mips/ingenic_x1000/clk-x1000.h13
-rw-r--r--firmware/target/mips/ingenic_x1000/dma-x1000.h2
-rw-r--r--firmware/target/mips/ingenic_x1000/gpio-x1000.c10
-rw-r--r--firmware/target/mips/ingenic_x1000/gpio-x1000.h11
-rw-r--r--firmware/target/mips/ingenic_x1000/system-target.h2
-rw-r--r--firmware/target/mips/ingenic_x1000/system-x1000.c1
6 files changed, 19 insertions, 20 deletions
diff --git a/firmware/target/mips/ingenic_x1000/clk-x1000.h b/firmware/target/mips/ingenic_x1000/clk-x1000.h
index f7153da564..4b1d4ef838 100644
--- a/firmware/target/mips/ingenic_x1000/clk-x1000.h
+++ b/firmware/target/mips/ingenic_x1000/clk-x1000.h
@@ -22,8 +22,9 @@
22#ifndef __CLK_X1000_H__ 22#ifndef __CLK_X1000_H__
23#define __CLK_X1000_H__ 23#define __CLK_X1000_H__
24 24
25#include <stdint.h> 25#include "config.h"
26#include "x1000/cpm.h" 26#include "x1000/cpm.h"
27#include <stdint.h>
27 28
28/* Used as arguments to clk_set_ccr_mux() */ 29/* Used as arguments to clk_set_ccr_mux() */
29#define CLKMUX_SCLK_A(x) jz_orf(CPM_CCR, SEL_SRC_V(x)) 30#define CLKMUX_SCLK_A(x) jz_orf(CPM_CCR, SEL_SRC_V(x))
@@ -67,17 +68,17 @@ extern uint32_t clk_get(x1000_clk_t clk);
67extern const char* clk_get_name(x1000_clk_t clk); 68extern const char* clk_get_name(x1000_clk_t clk);
68 69
69/* Clock initialization */ 70/* Clock initialization */
70extern void clk_init_early(void); 71extern void clk_init_early(void) INIT_ATTR;
71extern void clk_init(void); 72extern void clk_init(void) INIT_ATTR;
72 73
73/* Sets system clock multiplexers */ 74/* Sets system clock multiplexers */
74extern void clk_set_ccr_mux(uint32_t muxbits); 75extern void clk_set_ccr_mux(uint32_t muxbits) INIT_ATTR;
75 76
76/* Sets system clock dividers */ 77/* Sets system clock dividers */
77extern void clk_set_ccr_div(uint32_t divbits); 78extern void clk_set_ccr_div(uint32_t divbits) INIT_ATTR;
78 79
79/* Sets DDR clock source and divider */ 80/* Sets DDR clock source and divider */
80extern void clk_set_ddr(x1000_clk_t src, uint32_t div); 81extern void clk_set_ddr(x1000_clk_t src, uint32_t div) INIT_ATTR;
81 82
82/* Returns the smallest n such that infreq/n <= outfreq */ 83/* Returns the smallest n such that infreq/n <= outfreq */
83static inline uint32_t clk_calc_div(uint32_t infreq, uint32_t outfreq) 84static inline uint32_t clk_calc_div(uint32_t infreq, uint32_t outfreq)
diff --git a/firmware/target/mips/ingenic_x1000/dma-x1000.h b/firmware/target/mips/ingenic_x1000/dma-x1000.h
index 8bb5f1ddaa..4a526cec02 100644
--- a/firmware/target/mips/ingenic_x1000/dma-x1000.h
+++ b/firmware/target/mips/ingenic_x1000/dma-x1000.h
@@ -64,7 +64,7 @@ typedef struct dma_desc dma_desc;
64 64
65typedef void(*dma_cb_func)(int event); 65typedef void(*dma_cb_func)(int event);
66 66
67extern void dma_init(void); 67extern void dma_init(void) INIT_ATTR;
68extern void dma_set_callback(int chn, dma_cb_func cb); 68extern void dma_set_callback(int chn, dma_cb_func cb);
69 69
70#endif /* __DMA_X1000_H__ */ 70#endif /* __DMA_X1000_H__ */
diff --git a/firmware/target/mips/ingenic_x1000/gpio-x1000.c b/firmware/target/mips/ingenic_x1000/gpio-x1000.c
index 14195359df..0ebe424566 100644
--- a/firmware/target/mips/ingenic_x1000/gpio-x1000.c
+++ b/firmware/target/mips/ingenic_x1000/gpio-x1000.c
@@ -21,7 +21,7 @@
21 21
22#include "gpio-x1000.h" 22#include "gpio-x1000.h"
23 23
24const struct gpio_setting gpio_settings[PIN_COUNT] = { 24static const struct gpio_setting gpio_settings[PIN_COUNT] INITDATA_ATTR = {
25#define DEFINE_GPIO(_name, _gpio, _func) \ 25#define DEFINE_GPIO(_name, _gpio, _func) \
26 {.gpio = _gpio, .func = _func}, 26 {.gpio = _gpio, .func = _func},
27#define DEFINE_PINGROUP(...) 27#define DEFINE_PINGROUP(...)
@@ -30,7 +30,7 @@ const struct gpio_setting gpio_settings[PIN_COUNT] = {
30#undef DEFINE_PINGROUP 30#undef DEFINE_PINGROUP
31}; 31};
32 32
33const struct pingroup_setting pingroup_settings[PINGROUP_COUNT] = { 33static const struct pingroup_setting pingroup_settings[PINGROUP_COUNT] INITDATA_ATTR = {
34#define DEFINE_GPIO(...) 34#define DEFINE_GPIO(...)
35#define DEFINE_PINGROUP(_name, _port, _pins, _func) \ 35#define DEFINE_PINGROUP(_name, _port, _pins, _func) \
36 {.port = _port, .pins = _pins, .func = _func}, 36 {.port = _port, .pins = _pins, .func = _func},
@@ -39,7 +39,8 @@ const struct pingroup_setting pingroup_settings[PINGROUP_COUNT] = {
39#undef DEFINE_PINGROUP 39#undef DEFINE_PINGROUP
40}; 40};
41 41
42const char* const gpio_names[PIN_COUNT] = { 42#if 0 /* not needed for the time being */
43static const char* const gpio_names[PIN_COUNT] = {
43#define DEFINE_GPIO(_name, ...) #_name, 44#define DEFINE_GPIO(_name, ...) #_name,
44#define DEFINE_PINGROUP(...) 45#define DEFINE_PINGROUP(...)
45#include "gpio-target.h" 46#include "gpio-target.h"
@@ -47,13 +48,14 @@ const char* const gpio_names[PIN_COUNT] = {
47#undef DEFINE_PINGROUP 48#undef DEFINE_PINGROUP
48}; 49};
49 50
50const char* const pingroup_names[PINGROUP_COUNT] = { 51static const char* const pingroup_names[PINGROUP_COUNT] = {
51#define DEFINE_GPIO(...) 52#define DEFINE_GPIO(...)
52#define DEFINE_PINGROUP(_name, ...) #_name, 53#define DEFINE_PINGROUP(_name, ...) #_name,
53#include "gpio-target.h" 54#include "gpio-target.h"
54#undef DEFINE_GPIO 55#undef DEFINE_GPIO
55#undef DEFINE_PINGROUP 56#undef DEFINE_PINGROUP
56}; 57};
58#endif
57 59
58void gpio_init(void) 60void gpio_init(void)
59{ 61{
diff --git a/firmware/target/mips/ingenic_x1000/gpio-x1000.h b/firmware/target/mips/ingenic_x1000/gpio-x1000.h
index eac5f8651f..310a457ab5 100644
--- a/firmware/target/mips/ingenic_x1000/gpio-x1000.h
+++ b/firmware/target/mips/ingenic_x1000/gpio-x1000.h
@@ -23,6 +23,7 @@
23#define __GPIO_X1000_H__ 23#define __GPIO_X1000_H__
24 24
25#include "x1000/gpio.h" 25#include "x1000/gpio.h"
26#include "config.h"
26 27
27/* GPIO port numbers */ 28/* GPIO port numbers */
28#define GPIO_A 0 29#define GPIO_A 0
@@ -103,16 +104,8 @@ enum {
103 PINGROUP_COUNT, 104 PINGROUP_COUNT,
104}; 105};
105 106
106/* arrays which define the target's GPIO settings */
107extern const struct gpio_setting gpio_settings[PIN_COUNT];
108extern const struct pingroup_setting pingroup_settings[PINGROUP_COUNT];
109
110/* stringified names for use in debug menus */
111extern const char* const gpio_names[PIN_COUNT];
112extern const char* const pingroup_names[PINGROUP_COUNT];
113
114/* called at early init to set up GPIOs */ 107/* called at early init to set up GPIOs */
115extern void gpio_init(void); 108extern void gpio_init(void) INIT_ATTR;
116 109
117/* Use GPIO Z to reconfigure several pins atomically */ 110/* Use GPIO Z to reconfigure several pins atomically */
118extern void gpioz_configure(int port, uint32_t pins, int func); 111extern void gpioz_configure(int port, uint32_t pins, int func);
diff --git a/firmware/target/mips/ingenic_x1000/system-target.h b/firmware/target/mips/ingenic_x1000/system-target.h
index 59f1b73c5d..ed077a3cce 100644
--- a/firmware/target/mips/ingenic_x1000/system-target.h
+++ b/firmware/target/mips/ingenic_x1000/system-target.h
@@ -97,6 +97,8 @@ extern irq_handler_t system_set_irq_handler(int irq, irq_handler_t handler);
97extern void system_enable_irq(int irq); 97extern void system_enable_irq(int irq);
98extern void system_disable_irq(int irq); 98extern void system_disable_irq(int irq);
99 99
100extern void system_early_init(void) INIT_ATTR;
101
100/* Simple delay API */ 102/* Simple delay API */
101#define OST_FREQUENCY (X1000_EXCLK_FREQ / 4) 103#define OST_FREQUENCY (X1000_EXCLK_FREQ / 4)
102#define OST_TICKS_PER_US (OST_FREQUENCY / 1000000) 104#define OST_TICKS_PER_US (OST_FREQUENCY / 1000000)
diff --git a/firmware/target/mips/ingenic_x1000/system-x1000.c b/firmware/target/mips/ingenic_x1000/system-x1000.c
index efcc35aa86..64890a6c3a 100644
--- a/firmware/target/mips/ingenic_x1000/system-x1000.c
+++ b/firmware/target/mips/ingenic_x1000/system-x1000.c
@@ -44,6 +44,7 @@ uint32_t __cpu_idle_reftick = 0;
44#endif 44#endif
45 45
46/* Prepare the CPU to process interrupts, but don't enable them yet */ 46/* Prepare the CPU to process interrupts, but don't enable them yet */
47static void system_init_irq(void) INIT_ATTR;
47static void system_init_irq(void) 48static void system_init_irq(void)
48{ 49{
49 /* Mask all interrupts */ 50 /* Mask all interrupts */