diff options
Diffstat (limited to 'firmware/target/arm/imx233')
-rw-r--r-- | firmware/target/arm/imx233/clkctrl-imx233.c | 28 | ||||
-rw-r--r-- | firmware/target/arm/imx233/clkctrl-imx233.h | 2 | ||||
-rw-r--r-- | firmware/target/arm/imx233/nand-imx233.c | 4 | ||||
-rw-r--r-- | firmware/target/arm/imx233/partitions-imx233.c | 8 | ||||
-rw-r--r-- | firmware/target/arm/imx233/partitions-imx233.h | 6 | ||||
-rw-r--r-- | firmware/target/arm/imx233/sdmmc-imx233.c | 20 |
6 files changed, 46 insertions, 22 deletions
diff --git a/firmware/target/arm/imx233/clkctrl-imx233.c b/firmware/target/arm/imx233/clkctrl-imx233.c index 59c23c1a76..1a8f523d5a 100644 --- a/firmware/target/arm/imx233/clkctrl-imx233.c +++ b/firmware/target/arm/imx233/clkctrl-imx233.c | |||
@@ -87,7 +87,9 @@ void imx233_clkctrl_set_div(enum imx233_clock_t clk, int div) | |||
87 | case CLK_EMI: BF_WR(CLKCTRL_EMI, DIV(div)); break; | 87 | case CLK_EMI: BF_WR(CLKCTRL_EMI, DIV(div)); break; |
88 | #endif | 88 | #endif |
89 | case CLK_SSP: BF_WR(CLKCTRL_SSP, DIV(div)); break; | 89 | case CLK_SSP: BF_WR(CLKCTRL_SSP, DIV(div)); break; |
90 | case CLK_HBUS: BF_WR(CLKCTRL_HBUS, DIV(div)); break; | 90 | case CLK_HBUS: |
91 | /* make sure to switch to integer divide mode simulteanously */ | ||
92 | BF_WR(CLKCTRL_HBUS, DIV_FRAC_EN(0), DIV(div)); break; | ||
91 | case CLK_XBUS: BF_WR(CLKCTRL_XBUS, DIV(div)); break; | 93 | case CLK_XBUS: BF_WR(CLKCTRL_XBUS, DIV(div)); break; |
92 | default: return; | 94 | default: return; |
93 | } | 95 | } |
@@ -107,7 +109,12 @@ int imx233_clkctrl_get_div(enum imx233_clock_t clk) | |||
107 | case CLK_EMI: return BF_RD(CLKCTRL_EMI, DIV); | 109 | case CLK_EMI: return BF_RD(CLKCTRL_EMI, DIV); |
108 | #endif | 110 | #endif |
109 | case CLK_SSP: return BF_RD(CLKCTRL_SSP, DIV); | 111 | case CLK_SSP: return BF_RD(CLKCTRL_SSP, DIV); |
110 | case CLK_HBUS: return BF_RD(CLKCTRL_HBUS, DIV); | 112 | case CLK_HBUS: |
113 | /* since fractional and integer divider share the same field, clain it is disabled in frac mode */ | ||
114 | if(BF_RD(CLKCTRL_HBUS, DIV_FRAC_EN)) | ||
115 | return 0; | ||
116 | else | ||
117 | return BF_RD(CLKCTRL_HBUS, DIV); | ||
111 | case CLK_XBUS: return BF_RD(CLKCTRL_XBUS, DIV); | 118 | case CLK_XBUS: return BF_RD(CLKCTRL_XBUS, DIV); |
112 | default: return 0; | 119 | default: return 0; |
113 | } | 120 | } |
@@ -130,6 +137,14 @@ void imx233_clkctrl_set_frac_div(enum imx233_clock_t clk, int fracdiv) | |||
130 | handle_frac(IO) | 137 | handle_frac(IO) |
131 | handle_frac(CPU) | 138 | handle_frac(CPU) |
132 | handle_frac(EMI) | 139 | handle_frac(EMI) |
140 | case CLK_HBUS: | ||
141 | if(fracdiv == 0) | ||
142 | panicf("Don't set hbus fracdiv to 0!"); | ||
143 | /* value 0 is forbidden because we can't simply disabble the divider, it's always | ||
144 | * active but either in integer or fractional mode | ||
145 | * make sure we write both the value and frac_en bit at the same time */ | ||
146 | BF_WR(CLKCTRL_HBUS, DIV_FRAC_EN(1), DIV(fracdiv)); | ||
147 | break; | ||
133 | default: break; | 148 | default: break; |
134 | } | 149 | } |
135 | #undef handle_frac | 150 | #undef handle_frac |
@@ -151,6 +166,11 @@ int imx233_clkctrl_get_frac_div(enum imx233_clock_t clk) | |||
151 | handle_frac(IO) | 166 | handle_frac(IO) |
152 | handle_frac(CPU) | 167 | handle_frac(CPU) |
153 | handle_frac(EMI) | 168 | handle_frac(EMI) |
169 | case CLK_HBUS: | ||
170 | if(BF_RD(CLKCTRL_HBUS, DIV_FRAC_EN)) | ||
171 | return BF_RD(CLKCTRL_HBUS, DIV); | ||
172 | else | ||
173 | return 0; | ||
154 | default: return 0; | 174 | default: return 0; |
155 | } | 175 | } |
156 | #undef handle_frac | 176 | #undef handle_frac |
@@ -303,8 +323,12 @@ unsigned imx233_clkctrl_get_freq(enum imx233_clock_t clk) | |||
303 | /* Derived from clk_p via integer/fractional div */ | 323 | /* Derived from clk_p via integer/fractional div */ |
304 | unsigned ref = imx233_clkctrl_get_freq(CLK_CPU); | 324 | unsigned ref = imx233_clkctrl_get_freq(CLK_CPU); |
305 | #if IMX233_SUBTARGET >= 3700 | 325 | #if IMX233_SUBTARGET >= 3700 |
326 | /* if divider is in fractional mode, integer divider does not take effect (in fact it's | ||
327 | * the same divider but in a different mode ). Also the fractiona value is encoded as | ||
328 | * a fraction, not a divider */ | ||
306 | if(imx233_clkctrl_get_frac_div(CLK_HBUS) != 0) | 329 | if(imx233_clkctrl_get_frac_div(CLK_HBUS) != 0) |
307 | ref = (ref * imx233_clkctrl_get_frac_div(CLK_HBUS)) / 32; | 330 | ref = (ref * imx233_clkctrl_get_frac_div(CLK_HBUS)) / 32; |
331 | else | ||
308 | #endif | 332 | #endif |
309 | if(imx233_clkctrl_get_div(CLK_HBUS) != 0) | 333 | if(imx233_clkctrl_get_div(CLK_HBUS) != 0) |
310 | ref /= imx233_clkctrl_get_div(CLK_HBUS); | 334 | ref /= imx233_clkctrl_get_div(CLK_HBUS); |
diff --git a/firmware/target/arm/imx233/clkctrl-imx233.h b/firmware/target/arm/imx233/clkctrl-imx233.h index f12d181c50..d150912cfe 100644 --- a/firmware/target/arm/imx233/clkctrl-imx233.h +++ b/firmware/target/arm/imx233/clkctrl-imx233.h | |||
@@ -68,7 +68,7 @@ int imx233_clkctrl_get_div(enum imx233_clock_t clk); | |||
68 | #if IMX233_SUBTARGET >= 3700 | 68 | #if IMX233_SUBTARGET >= 3700 |
69 | /* call with fracdiv=0 to disable it */ | 69 | /* call with fracdiv=0 to disable it */ |
70 | void imx233_clkctrl_set_frac_div(enum imx233_clock_t clk, int fracdiv); | 70 | void imx233_clkctrl_set_frac_div(enum imx233_clock_t clk, int fracdiv); |
71 | /* 0 means fractional dividor disable */ | 71 | /* 0 means fractional dividor disabled */ |
72 | int imx233_clkctrl_get_frac_div(enum imx233_clock_t clk); | 72 | int imx233_clkctrl_get_frac_div(enum imx233_clock_t clk); |
73 | void imx233_clkctrl_set_bypass(enum imx233_clock_t clk, bool bypass); | 73 | void imx233_clkctrl_set_bypass(enum imx233_clock_t clk, bool bypass); |
74 | bool imx233_clkctrl_get_bypass(enum imx233_clock_t clk); | 74 | bool imx233_clkctrl_get_bypass(enum imx233_clock_t clk); |
diff --git a/firmware/target/arm/imx233/nand-imx233.c b/firmware/target/arm/imx233/nand-imx233.c index a7afba7d43..22da408e05 100644 --- a/firmware/target/arm/imx233/nand-imx233.c +++ b/firmware/target/arm/imx233/nand-imx233.c | |||
@@ -36,13 +36,13 @@ int nand_init(void) | |||
36 | { | 36 | { |
37 | return -1; | 37 | return -1; |
38 | } | 38 | } |
39 | int nand_read_sectors(IF_MD(int drive,) unsigned long start, int count, | 39 | int nand_read_sectors(IF_MD(int drive,) sector_t start, int count, |
40 | void* buf) | 40 | void* buf) |
41 | { | 41 | { |
42 | return -1; | 42 | return -1; |
43 | } | 43 | } |
44 | 44 | ||
45 | int nand_write_sectors(IF_MD(int drive,) unsigned long start, int count, | 45 | int nand_write_sectors(IF_MD(int drive,) sector_t start, int count, |
46 | const void* buf) | 46 | const void* buf) |
47 | { | 47 | { |
48 | return -1; | 48 | return -1; |
diff --git a/firmware/target/arm/imx233/partitions-imx233.c b/firmware/target/arm/imx233/partitions-imx233.c index 83a0bf8b42..69d0ba4199 100644 --- a/firmware/target/arm/imx233/partitions-imx233.c +++ b/firmware/target/arm/imx233/partitions-imx233.c | |||
@@ -71,7 +71,7 @@ static const char *creative_part_name(enum imx233_part_t part) | |||
71 | } | 71 | } |
72 | 72 | ||
73 | static int compute_window_creative(intptr_t user, part_read_fn_t read_fn, | 73 | static int compute_window_creative(intptr_t user, part_read_fn_t read_fn, |
74 | enum imx233_part_t part, unsigned *start, unsigned *end) | 74 | enum imx233_part_t part, sector_t *start, sector_t *end) |
75 | { | 75 | { |
76 | uint8_t mblk[512]; | 76 | uint8_t mblk[512]; |
77 | int ret = read_fn(user, MBLK_ADDR / 512, 1, mblk); | 77 | int ret = read_fn(user, MBLK_ADDR / 512, 1, mblk); |
@@ -99,7 +99,7 @@ static int compute_window_creative(intptr_t user, part_read_fn_t read_fn, | |||
99 | } | 99 | } |
100 | else | 100 | else |
101 | *end = *start + ent[i].size * hdr->block_size / 512; | 101 | *end = *start + ent[i].size * hdr->block_size / 512; |
102 | 102 | ||
103 | return 0; | 103 | return 0; |
104 | } | 104 | } |
105 | } | 105 | } |
@@ -109,7 +109,7 @@ static int compute_window_creative(intptr_t user, part_read_fn_t read_fn, | |||
109 | 109 | ||
110 | #if (IMX233_PARTITIONS & IMX233_FREESCALE) | 110 | #if (IMX233_PARTITIONS & IMX233_FREESCALE) |
111 | static int compute_window_freescale(intptr_t user, part_read_fn_t read_fn, | 111 | static int compute_window_freescale(intptr_t user, part_read_fn_t read_fn, |
112 | enum imx233_part_t part, unsigned *start, unsigned *end) | 112 | enum imx233_part_t part, sector_t *start, sector_t *end) |
113 | { | 113 | { |
114 | uint8_t mbr[512]; | 114 | uint8_t mbr[512]; |
115 | int ret = read_fn(user, 0, 1, mbr); | 115 | int ret = read_fn(user, 0, 1, mbr); |
@@ -179,7 +179,7 @@ static int compute_window_freescale(intptr_t user, part_read_fn_t read_fn, | |||
179 | #endif /* (IMX233_PARTITIONS & IMX233_FREESCALE) */ | 179 | #endif /* (IMX233_PARTITIONS & IMX233_FREESCALE) */ |
180 | 180 | ||
181 | int imx233_partitions_compute_window(intptr_t user, part_read_fn_t read_fn, | 181 | int imx233_partitions_compute_window(intptr_t user, part_read_fn_t read_fn, |
182 | enum imx233_part_t part, unsigned *start, unsigned *end) | 182 | enum imx233_part_t part, sector_t *start, sector_t *end) |
183 | { | 183 | { |
184 | int ret = -1; | 184 | int ret = -1; |
185 | #if (IMX233_PARTITIONS & IMX233_CREATIVE) | 185 | #if (IMX233_PARTITIONS & IMX233_CREATIVE) |
diff --git a/firmware/target/arm/imx233/partitions-imx233.h b/firmware/target/arm/imx233/partitions-imx233.h index e5378dadbb..edc6c1b2f4 100644 --- a/firmware/target/arm/imx233/partitions-imx233.h +++ b/firmware/target/arm/imx233/partitions-imx233.h | |||
@@ -45,7 +45,7 @@ enum imx233_part_t | |||
45 | /** The computation function can be called very early in the boot, at which point | 45 | /** The computation function can be called very early in the boot, at which point |
46 | * usual storage read/write function may not be available. To workaround this | 46 | * usual storage read/write function may not be available. To workaround this |
47 | * issue, one must provide a read function. */ | 47 | * issue, one must provide a read function. */ |
48 | typedef int (*part_read_fn_t)(intptr_t user, unsigned long start, int count, void* buf); | 48 | typedef int (*part_read_fn_t)(intptr_t user, sector_t start, int count, void* buf); |
49 | /* Enable/Disable window computations for internal storage following the | 49 | /* Enable/Disable window computations for internal storage following the |
50 | * Freescale/Creative convention */ | 50 | * Freescale/Creative convention */ |
51 | void imx233_partitions_enable_window(bool enable); | 51 | void imx233_partitions_enable_window(bool enable); |
@@ -55,6 +55,6 @@ bool imx233_partitions_is_window_enabled(void); | |||
55 | * for a whole disk, *end should be the size of the disk when the function is | 55 | * for a whole disk, *end should be the size of the disk when the function is |
56 | * called */ | 56 | * called */ |
57 | int imx233_partitions_compute_window(intptr_t user, part_read_fn_t read_fn, | 57 | int imx233_partitions_compute_window(intptr_t user, part_read_fn_t read_fn, |
58 | enum imx233_part_t part, unsigned *start, unsigned *end); | 58 | enum imx233_part_t part, sector_t *start, sector_t *end); |
59 | 59 | ||
60 | #endif /* __PARTITIONS_IMX233__ */ \ No newline at end of file | 60 | #endif /* __PARTITIONS_IMX233__ */ |
diff --git a/firmware/target/arm/imx233/sdmmc-imx233.c b/firmware/target/arm/imx233/sdmmc-imx233.c index af090e8a07..02f59a50f4 100644 --- a/firmware/target/arm/imx233/sdmmc-imx233.c +++ b/firmware/target/arm/imx233/sdmmc-imx233.c | |||
@@ -203,8 +203,8 @@ struct sdmmc_status_t | |||
203 | * the RCA is the 16-bit msb. Be careful that this is not the actuall RCA ! */ | 203 | * the RCA is the 16-bit msb. Be careful that this is not the actuall RCA ! */ |
204 | 204 | ||
205 | /* common */ | 205 | /* common */ |
206 | static unsigned window_start[SDMMC_NUM_DRIVES]; | 206 | static sector_t window_start[SDMMC_NUM_DRIVES]; |
207 | static unsigned window_end[SDMMC_NUM_DRIVES]; | 207 | static sector_t window_end[SDMMC_NUM_DRIVES]; |
208 | static uint8_t aligned_buffer[SDMMC_NUM_DRIVES][512] CACHEALIGN_ATTR; | 208 | static uint8_t aligned_buffer[SDMMC_NUM_DRIVES][512] CACHEALIGN_ATTR; |
209 | static tCardInfo sdmmc_card_info[SDMMC_NUM_DRIVES]; | 209 | static tCardInfo sdmmc_card_info[SDMMC_NUM_DRIVES]; |
210 | static struct mutex mutex[SDMMC_NUM_DRIVES]; | 210 | static struct mutex mutex[SDMMC_NUM_DRIVES]; |
@@ -648,7 +648,7 @@ int mmc_event(long id, intptr_t data) | |||
648 | #endif /* CONFIG_STORAGE & STORAGE_MMC */ | 648 | #endif /* CONFIG_STORAGE & STORAGE_MMC */ |
649 | 649 | ||
650 | /* low-level function, don't call directly! */ | 650 | /* low-level function, don't call directly! */ |
651 | static int __xfer_sectors(int drive, unsigned long start, int count, void *buf, bool read) | 651 | static int __xfer_sectors(int drive, sector_t start, int count, void *buf, bool read) |
652 | { | 652 | { |
653 | uint32_t resp; | 653 | uint32_t resp; |
654 | int ret = 0; | 654 | int ret = 0; |
@@ -660,7 +660,7 @@ static int __xfer_sectors(int drive, unsigned long start, int count, void *buf, | |||
660 | need_stop = false; | 660 | need_stop = false; |
661 | /* Set bank_start to the correct unit (blocks or bytes). | 661 | /* Set bank_start to the correct unit (blocks or bytes). |
662 | * MMC drives use block addressing, SD cards bytes or blocks */ | 662 | * MMC drives use block addressing, SD cards bytes or blocks */ |
663 | int bank_start = start; | 663 | sector_t bank_start = start; |
664 | if(SDMMC_MODE(drive) == SD_MODE && !(SDMMC_INFO(drive).ocr & (1<<30))) /* not SDHC */ | 664 | if(SDMMC_MODE(drive) == SD_MODE && !(SDMMC_INFO(drive).ocr & (1<<30))) /* not SDHC */ |
665 | bank_start *= SD_BLOCK_SIZE; | 665 | bank_start *= SD_BLOCK_SIZE; |
666 | /* issue read/write | 666 | /* issue read/write |
@@ -686,7 +686,7 @@ static int __xfer_sectors(int drive, unsigned long start, int count, void *buf, | |||
686 | return ret; | 686 | return ret; |
687 | } | 687 | } |
688 | 688 | ||
689 | static int transfer_sectors(int drive, unsigned long start, int count, void *buf, bool read) | 689 | static int transfer_sectors(int drive, sector_t start, int count, void *buf, bool read) |
690 | { | 690 | { |
691 | int ret = 0; | 691 | int ret = 0; |
692 | /* the function doesn't work when count is 0 */ | 692 | /* the function doesn't work when count is 0 */ |
@@ -806,7 +806,7 @@ static int transfer_sectors(int drive, unsigned long start, int count, void *buf | |||
806 | } | 806 | } |
807 | 807 | ||
808 | /* user specifies the sdmmc drive */ | 808 | /* user specifies the sdmmc drive */ |
809 | static int part_read_fn(intptr_t user, unsigned long start, int count, void* buf) | 809 | static int part_read_fn(intptr_t user, sector_t start, int count, void* buf) |
810 | { | 810 | { |
811 | return transfer_sectors(user, start, count, buf, true); | 811 | return transfer_sectors(user, start, count, buf, true); |
812 | } | 812 | } |
@@ -917,7 +917,7 @@ void sd_enable(bool on) | |||
917 | (void) on; | 917 | (void) on; |
918 | } | 918 | } |
919 | 919 | ||
920 | int sd_read_sectors(IF_MD(int sd_drive,) unsigned long start, int count, void *buf) | 920 | int sd_read_sectors(IF_MD(int sd_drive,) sector_t start, int count, void *buf) |
921 | { | 921 | { |
922 | #ifndef HAVE_MULTIDRIVE | 922 | #ifndef HAVE_MULTIDRIVE |
923 | int sd_drive = 0; | 923 | int sd_drive = 0; |
@@ -925,7 +925,7 @@ int sd_read_sectors(IF_MD(int sd_drive,) unsigned long start, int count, void *b | |||
925 | return transfer_sectors(sd_map[sd_drive], start, count, buf, true); | 925 | return transfer_sectors(sd_map[sd_drive], start, count, buf, true); |
926 | } | 926 | } |
927 | 927 | ||
928 | int sd_write_sectors(IF_MD(int sd_drive,) unsigned long start, int count, const void* buf) | 928 | int sd_write_sectors(IF_MD(int sd_drive,) sector_t start, int count, const void* buf) |
929 | { | 929 | { |
930 | #ifndef HAVE_MULTIDRIVE | 930 | #ifndef HAVE_MULTIDRIVE |
931 | int sd_drive = 0; | 931 | int sd_drive = 0; |
@@ -1039,7 +1039,7 @@ int mmc_spinup_time(void) | |||
1039 | return 0; | 1039 | return 0; |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | int mmc_read_sectors(IF_MD(int mmc_drive,) unsigned long start, int count, void *buf) | 1042 | int mmc_read_sectors(IF_MD(int mmc_drive,) sector_t start, int count, void *buf) |
1043 | { | 1043 | { |
1044 | #ifndef HAVE_MULTIDRIVE | 1044 | #ifndef HAVE_MULTIDRIVE |
1045 | int mmc_drive = 0; | 1045 | int mmc_drive = 0; |
@@ -1047,7 +1047,7 @@ int mmc_read_sectors(IF_MD(int mmc_drive,) unsigned long start, int count, void | |||
1047 | return transfer_sectors(mmc_map[mmc_drive], start, count, buf, true); | 1047 | return transfer_sectors(mmc_map[mmc_drive], start, count, buf, true); |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | int mmc_write_sectors(IF_MD(int mmc_drive,) unsigned long start, int count, const void* buf) | 1050 | int mmc_write_sectors(IF_MD(int mmc_drive,) sector_t start, int count, const void* buf) |
1051 | { | 1051 | { |
1052 | #ifndef HAVE_MULTIDRIVE | 1052 | #ifndef HAVE_MULTIDRIVE |
1053 | int mmc_drive = 0; | 1053 | int mmc_drive = 0; |