Skip to content

Commit

Permalink
sunxi: Add video pll clock functions
Browse files Browse the repository at this point in the history
This is a preparation patch for adding support for HDMI out.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  • Loading branch information
jwrdegoede committed Nov 8, 2014
1 parent 0a7e06c commit 1c56848
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
15 changes: 15 additions & 0 deletions arch/arm/cpu/armv7/sunxi/clock_sun4i.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@ void clock_set_pll1(unsigned int hz)
}
#endif

void clock_set_pll3(unsigned int clk)
{
struct sunxi_ccm_reg * const ccm =
(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;

if (clk == 0) {
clrbits_le32(&ccm->pll3_cfg, CCM_PLL3_CTRL_EN);
return;
}

/* PLL3 rate = 3000000 * m */
writel(CCM_PLL3_CTRL_EN | CCM_PLL3_CTRL_INTEGER_MODE |
CCM_PLL3_CTRL_M(clk / 3000000), &ccm->pll3_cfg);
}

unsigned int clock_get_pll5p(void)
{
struct sunxi_ccm_reg *const ccm =
Expand Down
17 changes: 17 additions & 0 deletions arch/arm/cpu/armv7/sunxi/clock_sun6i.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,23 @@ void clock_set_pll1(unsigned int clk)
}
#endif

void clock_set_pll3(unsigned int clk)
{
struct sunxi_ccm_reg * const ccm =
(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
const int m = 8; /* 3 MHz steps just like sun4i, sun5i and sun7i */

if (clk == 0) {
clrbits_le32(&ccm->pll3_cfg, CCM_PLL3_CTRL_EN);
return;
}

/* PLL3 rate = 24000000 * n / m */
writel(CCM_PLL3_CTRL_EN | CCM_PLL3_CTRL_INTEGER_MODE |
CCM_PLL3_CTRL_N(clk / (24000000 / m)) | CCM_PLL3_CTRL_M(m),
&ccm->pll3_cfg);
}

void clock_set_pll5(unsigned int clk)
{
struct sunxi_ccm_reg * const ccm =
Expand Down
1 change: 1 addition & 0 deletions arch/arm/include/asm/arch-sunxi/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
int clock_init(void);
int clock_twi_onoff(int port, int state);
void clock_set_pll1(unsigned int hz);
void clock_set_pll3(unsigned int hz);
void clock_set_pll5(unsigned int hz);
unsigned int clock_get_pll5p(void);
unsigned int clock_get_pll6(void);
Expand Down
4 changes: 4 additions & 0 deletions arch/arm/include/asm/arch-sunxi/clock_sun4i.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ struct sunxi_ccm_reg {
#define CCM_AHB_GATE_DLL (0x1 << 15)
#define CCM_AHB_GATE_ACE (0x1 << 16)

#define CCM_PLL3_CTRL_M(n) (((n) & 0x7f) << 0)
#define CCM_PLL3_CTRL_INTEGER_MODE (0x1 << 15)
#define CCM_PLL3_CTRL_EN (0x1 << 31)

#define CCM_PLL5_CTRL_M(n) (((n) & 0x3) << 0)
#define CCM_PLL5_CTRL_M_MASK CCM_PLL5_CTRL_M(0x3)
#define CCM_PLL5_CTRL_M_X(n) ((n) - 1)
Expand Down
7 changes: 6 additions & 1 deletion arch/arm/include/asm/arch-sunxi/clock_sun6i.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,18 @@ struct sunxi_ccm_reg {
#define CCM_PLL1_CTRL_MAGIC (0x1 << 16)
#define CCM_PLL1_CTRL_EN (0x1 << 31)

#define CCM_PLL3_CTRL_M(n) ((((n) - 1) & 0xf) << 0)
#define CCM_PLL3_CTRL_N(n) ((((n) - 1) & 0x7f) << 8)
#define CCM_PLL3_CTRL_INTEGER_MODE (0x1 << 24)
#define CCM_PLL3_CTRL_EN (0x1 << 31)

#define CCM_PLL5_CTRL_M(n) ((((n) - 1) & 0x3) << 0)
#define CCM_PLL5_CTRL_K(n) ((((n) - 1) & 0x3) << 4)
#define CCM_PLL5_CTRL_N(n) ((((n) - 1) & 0x1f) << 8)
#define CCM_PLL5_CTRL_UPD (0x1 << 20)
#define CCM_PLL5_CTRL_EN (0x1 << 31)

#define PLL6_CFG_DEFAULT 0x90041811
#define PLL6_CFG_DEFAULT 0x90041811 /* 600 MHz */

#define CCM_PLL6_CTRL_N_SHIFT 8
#define CCM_PLL6_CTRL_N_MASK (0x1f << CCM_PLL6_CTRL_N_SHIFT)
Expand Down

0 comments on commit 1c56848

Please sign in to comment.