2014-04-09 03:45:46 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2012 - 2013 The Linux Foundation. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2014-04-10 04:23:54 +02:00
|
|
|
#include <delay.h>
|
2014-10-20 22:20:49 +02:00
|
|
|
#include <soc/clock.h>
|
2015-01-26 04:08:42 +01:00
|
|
|
#include <types.h>
|
2014-04-09 03:45:46 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* uart_pll_vote_clk_enable - enables PLL8
|
|
|
|
*/
|
|
|
|
void uart_pll_vote_clk_enable(unsigned int clk_dummy)
|
|
|
|
{
|
|
|
|
setbits_le32(BB_PLL_ENA_SC0_REG, BIT(8));
|
|
|
|
|
|
|
|
if (!clk_dummy)
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
while((read32(PLL_LOCK_DET_STATUS_REG) & BIT(8)) == 0);
|
2014-04-09 03:45:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* uart_set_rate_mnd - configures divider M and D values
|
|
|
|
*
|
|
|
|
* Sets the M, D parameters of the divider to generate the GSBI UART
|
|
|
|
* apps clock.
|
|
|
|
*/
|
|
|
|
static void uart_set_rate_mnd(unsigned int gsbi_port, unsigned int m,
|
|
|
|
unsigned int n)
|
|
|
|
{
|
|
|
|
/* Assert MND reset. */
|
|
|
|
setbits_le32(GSBIn_UART_APPS_NS_REG(gsbi_port), BIT(7));
|
|
|
|
/* Program M and D values. */
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(GSBIn_UART_APPS_MD_REG(gsbi_port), MD16(m, n));
|
2014-04-09 03:45:46 +02:00
|
|
|
/* Deassert MND reset. */
|
|
|
|
clrbits_le32(GSBIn_UART_APPS_NS_REG(gsbi_port), BIT(7));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* uart_branch_clk_enable_reg - enables branch clock
|
|
|
|
*
|
|
|
|
* Enables branch clock for GSBI UART port.
|
|
|
|
*/
|
|
|
|
static void uart_branch_clk_enable_reg(unsigned int gsbi_port)
|
|
|
|
{
|
|
|
|
setbits_le32(GSBIn_UART_APPS_NS_REG(gsbi_port), BIT(9));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* uart_local_clock_enable - configures N value and enables root clocks
|
|
|
|
*
|
|
|
|
* Sets the N parameter of the divider and enables root clock and
|
|
|
|
* branch clocks for GSBI UART port.
|
|
|
|
*/
|
|
|
|
static void uart_local_clock_enable(unsigned int gsbi_port, unsigned int n,
|
|
|
|
unsigned int m)
|
|
|
|
{
|
|
|
|
unsigned int reg_val, uart_ns_val;
|
|
|
|
void *const reg = (void *)GSBIn_UART_APPS_NS_REG(gsbi_port);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Program the NS register, if applicable. NS registers are not
|
|
|
|
* set in the set_rate path because power can be saved by deferring
|
|
|
|
* the selection of a clocked source until the clock is enabled.
|
|
|
|
*/
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
reg_val = read32(reg); // REG(0x29D4+(0x20*((n)-1)))
|
2014-04-09 03:45:46 +02:00
|
|
|
reg_val &= ~(Uart_clk_ns_mask);
|
|
|
|
uart_ns_val = NS(BIT_POS_31,BIT_POS_16,n,m, 5, 4, 3, 1, 2, 0,3);
|
|
|
|
reg_val |= (uart_ns_val & Uart_clk_ns_mask);
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(reg, reg_val);
|
2014-04-09 03:45:46 +02:00
|
|
|
|
|
|
|
/* enable MNCNTR_EN */
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
reg_val = read32(reg);
|
2014-04-09 03:45:46 +02:00
|
|
|
reg_val |= BIT(8);
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(reg, reg_val);
|
2014-04-09 03:45:46 +02:00
|
|
|
|
|
|
|
/* set source to PLL8 running @384MHz */
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
reg_val = read32(reg);
|
2014-04-09 03:45:46 +02:00
|
|
|
reg_val |= 0x3;
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(reg, reg_val);
|
2014-04-09 03:45:46 +02:00
|
|
|
|
|
|
|
/* Enable root. */
|
|
|
|
reg_val |= Uart_en_mask;
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(reg, reg_val);
|
2014-04-09 03:45:46 +02:00
|
|
|
uart_branch_clk_enable_reg(gsbi_port);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* uart_set_gsbi_clk - enables HCLK for UART GSBI port
|
|
|
|
*/
|
|
|
|
static void uart_set_gsbi_clk(unsigned int gsbi_port)
|
|
|
|
{
|
|
|
|
setbits_le32(GSBIn_HCLK_CTL_REG(gsbi_port), BIT(4));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* uart_clock_config - configures UART clocks
|
|
|
|
*
|
|
|
|
* Configures GSBI UART dividers, enable root and branch clocks.
|
|
|
|
*/
|
|
|
|
void uart_clock_config(unsigned int gsbi_port, unsigned int m,
|
|
|
|
unsigned int n, unsigned int d, unsigned int clk_dummy)
|
|
|
|
{
|
|
|
|
uart_set_rate_mnd(gsbi_port, m, d);
|
|
|
|
uart_pll_vote_clk_enable(clk_dummy);
|
|
|
|
uart_local_clock_enable(gsbi_port, n, m);
|
|
|
|
uart_set_gsbi_clk(gsbi_port);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* nand_clock_config - configure NAND controller clocks
|
|
|
|
*
|
|
|
|
* Enable clocks to EBI2. Must be invoked before touching EBI2
|
|
|
|
* registers.
|
|
|
|
*/
|
|
|
|
void nand_clock_config(void)
|
|
|
|
{
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(EBI2_CLK_CTL_REG,
|
|
|
|
CLK_BRANCH_ENA(1) | ALWAYS_ON_CLK_BRANCH_ENA(1));
|
2014-04-09 03:45:46 +02:00
|
|
|
|
|
|
|
/* Wait for clock to stabilize. */
|
|
|
|
udelay(10);
|
|
|
|
}
|
2014-05-31 03:01:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* usb_clock_config - configure USB controller clocks and reset the controller
|
|
|
|
*/
|
|
|
|
void usb_clock_config(void)
|
|
|
|
{
|
|
|
|
/* Magic clock initialization numbers, nobody knows how they work... */
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(USB30_MASTER_CLK_CTL_REG, 0x10);
|
|
|
|
write32(USB30_1_MASTER_CLK_CTL_REG, 0x10);
|
|
|
|
write32(USB30_MASTER_CLK_MD, 0x500DF);
|
|
|
|
write32(USB30_MASTER_CLK_NS, 0xE40942);
|
|
|
|
write32(USB30_MOC_UTMI_CLK_MD, 0x100D7);
|
|
|
|
write32(USB30_MOC_UTMI_CLK_NS, 0xD80942);
|
|
|
|
write32(USB30_MOC_UTMI_CLK_CTL, 0x10);
|
|
|
|
write32(USB30_1_MOC_UTMI_CLK_CTL, 0x10);
|
|
|
|
|
|
|
|
write32(USB30_RESET,
|
|
|
|
1 << 5 | 1 << 4 | 1 << 3 | 1 << 2 | 1 << 1 | 1 << 0 | 0);
|
2014-05-31 03:01:44 +02:00
|
|
|
udelay(5);
|
arm(64): Globally replace writel(v, a) with write32(a, v)
This patch is a raw application of the following spatch to src/:
@@
expression A, V;
@@
- writel(V, A)
+ write32(A, V)
@@
expression A, V;
@@
- writew(V, A)
+ write16(A, V)
@@
expression A, V;
@@
- writeb(V, A)
+ write8(A, V)
@@
expression A;
@@
- readl(A)
+ read32(A)
@@
expression A;
@@
- readb(A)
+ read8(A)
BRANCH=none
BUG=chromium:444723
TEST=None (depends on next patch)
Change-Id: I5dd96490c85ee2bcbc669f08bc6fff0ecc0f9e27
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 64f643da95d85954c4d4ea91c34a5c69b9b08eb6
Original-Change-Id: I366a2eb5b3a0df2279ebcce572fe814894791c42
Original-Signed-off-by: Julius Werner <jwerner@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/254864
Reviewed-on: http://review.coreboot.org/9836
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
2015-02-19 23:51:15 +01:00
|
|
|
write32(USB30_RESET, 0); /* deassert all USB resets again */
|
2014-05-31 03:01:44 +02:00
|
|
|
}
|