summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx31/gigabeat-s
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/ata-imx31.c2
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/button-imx31.c2
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/clkctl-imx31.c95
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/clkctl-imx31.h114
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/i2c-imx31.c2
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/kernel-imx31.c2
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/pcm-imx31.c2
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/spi-imx31.c2
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/system-imx31.c2
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/timer-imx31.c2
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/usb-imx31.c2
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/wmcodec-imx31.c8
12 files changed, 13 insertions, 222 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/ata-imx31.c b/firmware/target/arm/imx31/gigabeat-s/ata-imx31.c
index c941037317..5ce7ad0a03 100644
--- a/firmware/target/arm/imx31/gigabeat-s/ata-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/ata-imx31.c
@@ -27,7 +27,7 @@
27#include "panic.h" 27#include "panic.h"
28#include "ata.h" 28#include "ata.h"
29#include "ata-target.h" 29#include "ata-target.h"
30#include "clkctl-imx31.h" 30#include "ccm-imx31.h"
31#ifdef HAVE_ATA_DMA 31#ifdef HAVE_ATA_DMA
32#include "sdma-imx31.h" 32#include "sdma-imx31.h"
33#include "mmu-imx31.h" 33#include "mmu-imx31.h"
diff --git a/firmware/target/arm/imx31/gigabeat-s/button-imx31.c b/firmware/target/arm/imx31/gigabeat-s/button-imx31.c
index 505ba397d9..320af7ca66 100644
--- a/firmware/target/arm/imx31/gigabeat-s/button-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/button-imx31.c
@@ -27,7 +27,7 @@
27#include "system.h" 27#include "system.h"
28#include "backlight-target.h" 28#include "backlight-target.h"
29#include "avic-imx31.h" 29#include "avic-imx31.h"
30#include "clkctl-imx31.h" 30#include "ccm-imx31.h"
31#include "mc13783.h" 31#include "mc13783.h"
32 32
33/* Most code in here is taken from the Linux BSP provided by Freescale 33/* Most code in here is taken from the Linux BSP provided by Freescale
diff --git a/firmware/target/arm/imx31/gigabeat-s/clkctl-imx31.c b/firmware/target/arm/imx31/gigabeat-s/clkctl-imx31.c
deleted file mode 100644
index 761cf8f701..0000000000
--- a/firmware/target/arm/imx31/gigabeat-s/clkctl-imx31.c
+++ /dev/null
@@ -1,95 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (c) 2008 Michael Sevakis
11 *
12 * Clock control functions for IMX31 processor
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23#include "system.h"
24#include "cpu.h"
25#include "clkctl-imx31.h"
26
27unsigned int ccm_get_src_pll(void)
28{
29 return (CCM_PMCR0 & 0xC0000000) == 0 ? PLL_SERIAL : PLL_MCU;
30}
31
32void ccm_module_clock_gating(enum IMX31_CG_LIST cg, enum IMX31_CG_MODES mode)
33{
34 volatile unsigned long *reg;
35 unsigned long mask;
36 int shift;
37
38 if (cg >= CG_NUM_CLOCKS)
39 return;
40
41 reg = &CCM_CGR0 + cg / 16; /* Select CGR0, CGR1, CGR2 */
42 shift = 2*(cg % 16); /* Get field shift */
43 mask = CG_MASK << shift; /* Select field */
44
45 imx31_regmod32(reg, mode << shift, mask);
46}
47
48/* Get the PLL reference clock frequency in HZ */
49unsigned int ccm_get_pll_ref_clk(void)
50{
51 if ((CCM_CCMR & (3 << 1)) == (1 << 1))
52 return CONFIG_CLK32_FREQ * 1024;
53 else
54 return CONFIG_HCLK_FREQ;
55}
56
57/* Return PLL frequency in HZ */
58unsigned int ccm_get_pll(enum IMX31_PLLS pll)
59{
60 uint32_t infreq = ccm_get_pll_ref_clk();
61 uint32_t reg = (&CCM_MPCTL)[pll];
62 uint32_t mfn = reg & 0x3ff;
63 uint32_t pd = ((reg >> 26) & 0xf) + 1;
64 uint64_t mfd = ((reg >> 16) & 0x3ff) + 1;
65 uint32_t mfi = (reg >> 10) & 0xf;
66
67 mfi = mfi <= 5 ? 5 : mfi;
68
69 return 2*infreq*(mfi * mfd + mfn) / (mfd * pd);
70}
71
72unsigned int ccm_get_ipg_clk(void)
73{
74 unsigned int pllnum = ccm_get_src_pll();
75 unsigned int pll = ccm_get_pll(pllnum);
76 uint32_t reg = CCM_PDR0;
77 unsigned int max_pdf = ((reg >> 3) & 0x7) + 1;
78 unsigned int ipg_pdf = ((reg >> 6) & 0x3) + 1;
79
80 return pll / (max_pdf * ipg_pdf);
81}
82
83unsigned int ccm_get_ahb_clk(void)
84{
85 unsigned int pllnum = ccm_get_src_pll();
86 unsigned int pll = ccm_get_pll(pllnum);
87 unsigned int max_pdf = ((CCM_PDR0 >> 3) & 0x7) + 1;
88
89 return pll / max_pdf;
90}
91
92unsigned int ccm_get_ata_clk(void)
93{
94 return ccm_get_ipg_clk();
95}
diff --git a/firmware/target/arm/imx31/gigabeat-s/clkctl-imx31.h b/firmware/target/arm/imx31/gigabeat-s/clkctl-imx31.h
deleted file mode 100644
index e1057a9618..0000000000
--- a/firmware/target/arm/imx31/gigabeat-s/clkctl-imx31.h
+++ /dev/null
@@ -1,114 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (c) 2008 Michael Sevakis
11 *
12 * Clock control functions for IMX31 processor
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23#ifndef _CCM_IMX31_H_
24#define _CCM_IMX31_H_
25
26enum IMX31_CG_LIST
27{
28 /* CGR0 */
29 CG_SD_MMC1 = 0,
30 CG_SD_MMC2,
31 CG_GPT,
32 CG_EPIT1,
33 CG_EPIT2,
34 CG_IIM,
35 CG_ATA,
36 CG_SDMA,
37 CG_CSPI3,
38 CG_RNG,
39 CG_UART1,
40 CG_UART2,
41 CG_SSI1,
42 CG_I2C1,
43 CG_I2C2,
44 CG_I2C3,
45 /* CGR1 */
46 CG_HANTRO,
47 CG_MEMSTICK1,
48 CG_MEMSTICK2,
49 CG_CSI,
50 CG_RTC,
51 CG_WDOG,
52 CG_PWM,
53 CG_SIM,
54 CG_ECT,
55 CG_USBOTG,
56 CG_KPP,
57 CG_IPU,
58 CG_UART3,
59 CG_UART4,
60 CG_UART5,
61 CG_1_WIRE,
62 /* CGR2 */
63 CG_SSI2,
64 CG_CSPI1,
65 CG_CSPI2,
66 CG_GACC,
67 CG_EMI,
68 CG_RTIC,
69 CG_FIR,
70 CG_NUM_CLOCKS
71};
72
73enum IMX31_CG_MODES
74{
75 CGM_OFF = 0x0, /* Always off */
76 CGM_ON_RUN = 0x1, /* On in run mode, off in wait and doze */
77 CGM_ON_RUN_WAIT = 0x2, /* On in run and wait modes, off in doze */
78 CGM_ON_ALL = 0x3, /* Always on */
79};
80
81#define CG_MASK 0x3 /* bitmask */
82
83/* Enable or disable module clocks independently - module must _not_ be
84 * active! */
85void ccm_module_clock_gating(enum IMX31_CG_LIST cg,
86 enum IMX31_CG_MODES mode);
87
88enum IMX31_PLLS
89{
90 PLL_MCU = 0,
91 PLL_USB,
92 PLL_SERIAL,
93 NUM_PLLS,
94};
95
96#define CONFIG_CLK32_FREQ 32768
97#define CONFIG_HCLK_FREQ 27000000
98
99/* Get the PLL reference clock frequency in HZ */
100unsigned int ccm_get_pll_ref_clk(void);
101
102/* Return PLL frequency in HZ */
103unsigned int ccm_get_pll(enum IMX31_PLLS pll);
104
105/* Return ipg_clk in HZ */
106unsigned int ccm_get_ipg_clk(void);
107
108/* Return ahb_clk in HZ */
109unsigned int ccm_get_ahb_clk(void);
110
111/* Return the ATA frequency in HZ */
112unsigned int ccm_get_ata_clk(void);
113
114#endif /* _CCM_IMX31_H_ */
diff --git a/firmware/target/arm/imx31/gigabeat-s/i2c-imx31.c b/firmware/target/arm/imx31/gigabeat-s/i2c-imx31.c
index 05d761c9ce..1ffdce38ea 100644
--- a/firmware/target/arm/imx31/gigabeat-s/i2c-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/i2c-imx31.c
@@ -23,7 +23,7 @@
23#include "system.h" 23#include "system.h"
24#include "kernel.h" 24#include "kernel.h"
25#include "avic-imx31.h" 25#include "avic-imx31.h"
26#include "clkctl-imx31.h" 26#include "ccm-imx31.h"
27#include "i2c-imx31.h" 27#include "i2c-imx31.h"
28 28
29/* Forward interrupt handler declarations */ 29/* Forward interrupt handler declarations */
diff --git a/firmware/target/arm/imx31/gigabeat-s/kernel-imx31.c b/firmware/target/arm/imx31/gigabeat-s/kernel-imx31.c
index 01e9b8b721..4ed3b3053b 100644
--- a/firmware/target/arm/imx31/gigabeat-s/kernel-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/kernel-imx31.c
@@ -23,7 +23,7 @@
23#include "avic-imx31.h" 23#include "avic-imx31.h"
24#include "spi-imx31.h" 24#include "spi-imx31.h"
25#include "mc13783.h" 25#include "mc13783.h"
26#include "clkctl-imx31.h" 26#include "ccm-imx31.h"
27#include "sdma-imx31.h" 27#include "sdma-imx31.h"
28#include "kernel.h" 28#include "kernel.h"
29#include "thread.h" 29#include "thread.h"
diff --git a/firmware/target/arm/imx31/gigabeat-s/pcm-imx31.c b/firmware/target/arm/imx31/gigabeat-s/pcm-imx31.c
index 00f196a512..6cec3ecdd3 100644
--- a/firmware/target/arm/imx31/gigabeat-s/pcm-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/pcm-imx31.c
@@ -23,7 +23,7 @@
23#include "kernel.h" 23#include "kernel.h"
24#include "audio.h" 24#include "audio.h"
25#include "sound.h" 25#include "sound.h"
26#include "clkctl-imx31.h" 26#include "ccm-imx31.h"
27#include "sdma-imx31.h" 27#include "sdma-imx31.h"
28#include "mmu-imx31.h" 28#include "mmu-imx31.h"
29 29
diff --git a/firmware/target/arm/imx31/gigabeat-s/spi-imx31.c b/firmware/target/arm/imx31/gigabeat-s/spi-imx31.c
index f905057372..ac063f9b10 100644
--- a/firmware/target/arm/imx31/gigabeat-s/spi-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/spi-imx31.c
@@ -22,7 +22,7 @@
22#include "system.h" 22#include "system.h"
23#include "spi-imx31.h" 23#include "spi-imx31.h"
24#include "avic-imx31.h" 24#include "avic-imx31.h"
25#include "clkctl-imx31.h" 25#include "ccm-imx31.h"
26#include "debug.h" 26#include "debug.h"
27#include "kernel.h" 27#include "kernel.h"
28 28
diff --git a/firmware/target/arm/imx31/gigabeat-s/system-imx31.c b/firmware/target/arm/imx31/gigabeat-s/system-imx31.c
index c710c5b93c..de39128497 100644
--- a/firmware/target/arm/imx31/gigabeat-s/system-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/system-imx31.c
@@ -29,7 +29,7 @@
29#include "lcd.h" 29#include "lcd.h"
30#include "serial-imx31.h" 30#include "serial-imx31.h"
31#include "debug.h" 31#include "debug.h"
32#include "clkctl-imx31.h" 32#include "ccm-imx31.h"
33#include "mc13783.h" 33#include "mc13783.h"
34 34
35static unsigned long product_rev; 35static unsigned long product_rev;
diff --git a/firmware/target/arm/imx31/gigabeat-s/timer-imx31.c b/firmware/target/arm/imx31/gigabeat-s/timer-imx31.c
index c4734a543b..9de3a9e9ec 100644
--- a/firmware/target/arm/imx31/gigabeat-s/timer-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/timer-imx31.c
@@ -21,7 +21,7 @@
21#include "config.h" 21#include "config.h"
22#include "system.h" 22#include "system.h"
23#include "timer.h" 23#include "timer.h"
24#include "clkctl-imx31.h" 24#include "ccm-imx31.h"
25#include "avic-imx31.h" 25#include "avic-imx31.h"
26 26
27static void __attribute__((interrupt("IRQ"))) EPIT2_HANDLER(void) 27static void __attribute__((interrupt("IRQ"))) EPIT2_HANDLER(void)
diff --git a/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c b/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c
index 2011d0c633..64ff04e7ae 100644
--- a/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/usb-imx31.c
@@ -27,7 +27,7 @@
27#include "usb_core.h" 27#include "usb_core.h"
28#include "usb_drv.h" 28#include "usb_drv.h"
29#include "usb-target.h" 29#include "usb-target.h"
30#include "clkctl-imx31.h" 30#include "ccm-imx31.h"
31#include "power-imx31.h" 31#include "power-imx31.h"
32#include "avic-imx31.h" 32#include "avic-imx31.h"
33#include "mc13783.h" 33#include "mc13783.h"
diff --git a/firmware/target/arm/imx31/gigabeat-s/wmcodec-imx31.c b/firmware/target/arm/imx31/gigabeat-s/wmcodec-imx31.c
index cf9331144a..2572b88fee 100644
--- a/firmware/target/arm/imx31/gigabeat-s/wmcodec-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/wmcodec-imx31.c
@@ -53,10 +53,10 @@ void audiohw_init(void)
53 * INT_BIT_CLK (MCLK) / 1.5 = 11289600Hz = 256*fs = SYSCLK 53 * INT_BIT_CLK (MCLK) / 1.5 = 11289600Hz = 256*fs = SYSCLK
54 */ 54 */
55 imx31_regmod32(&CCM_PDR1, 55 imx31_regmod32(&CCM_PDR1,
56 (1-1) << CCM_PDR1_SSI1_PRE_PODF_POS | 56 ((1-1) << CCM_PDR1_SSI1_PRE_PODF_POS) |
57 (5-1) << CCM_PDR1_SSI1_PODF_POS | 57 ((5-1) << CCM_PDR1_SSI1_PODF_POS) |
58 (8-1) << CCM_PDR1_SSI2_PRE_PODF_POS, 58 ((8-1) << CCM_PDR1_SSI2_PRE_PODF_POS),
59 (64-1) << CCM_PDR1_SSI2_PODF_POS | 59 ((64-1) << CCM_PDR1_SSI2_PODF_POS) |
60 CCM_PDR1_SSI1_PODF | CCM_PDR1_SSI2_PODF | 60 CCM_PDR1_SSI1_PODF | CCM_PDR1_SSI2_PODF |
61 CCM_PDR1_SSI1_PRE_PODF | CCM_PDR1_SSI2_PRE_PODF); 61 CCM_PDR1_SSI1_PRE_PODF | CCM_PDR1_SSI2_PRE_PODF);
62 62