M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions
@@ -0,0 +1,474 @@
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <err.h>
#include <assert.h>
#include <debug.h>
#include <reg.h>
#include <platform/timer.h>
#include <platform/iomap.h>
#include <mmc.h>
#include <clock.h>
#include <platform/clock.h>
#include <blsp_qup.h>
void hsusb_clock_init(void)
{
int ret;
struct clk *iclk, *cclk;
ret = clk_get_set_enable("usb_iface_clk", 0, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set usb_iface_clk ret = %d\n", ret);
ASSERT(0);
}
ret = clk_get_set_enable("usb_core_clk", 75000000, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set usb_core_clk ret = %d\n", ret);
ASSERT(0);
}
mdelay(20);
iclk = clk_get("usb_iface_clk");
cclk = clk_get("usb_core_clk");
clk_disable(iclk);
clk_disable(cclk);
mdelay(20);
/* Start the block reset for usb */
writel(1, USB_HS_BCR);
mdelay(20);
/* Take usb block out of reset */
writel(0, USB_HS_BCR);
mdelay(20);
ret = clk_enable(iclk);
if(ret)
{
dprintf(CRITICAL, "failed to set usb_iface_clk after async ret = %d\n", ret);
ASSERT(0);
}
ret = clk_enable(cclk);
if(ret)
{
dprintf(CRITICAL, "failed to set usb_iface_clk after async ret = %d\n", ret);
ASSERT(0);
}
}
void clock_init_mmc(uint32_t interface)
{
char clk_name[64];
int ret;
snprintf(clk_name, 64, "sdc%u_iface_clk", interface);
/* enable interface clock */
ret = clk_get_set_enable(clk_name, 0, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set sdc1_iface_clk ret = %d\n", ret);
ASSERT(0);
}
}
/* Configure MMC clock */
void clock_config_mmc(uint32_t interface, uint32_t freq)
{
int ret;
uint32_t reg;
char clk_name[64];
snprintf(clk_name, 64, "sdc%u_core_clk", interface);
/* Disalbe MCI_CLK before changing the sdcc clock */
#ifndef MMC_SDHCI_SUPPORT
mmc_boot_mci_clk_disable();
#endif
if(freq == MMC_CLK_400KHZ)
{
ret = clk_get_set_enable(clk_name, 400000, 1);
}
else if(freq == MMC_CLK_50MHZ)
{
ret = clk_get_set_enable(clk_name, 50000000, 1);
}
else if(freq == MMC_CLK_96MHZ)
{
ret = clk_get_set_enable(clk_name, 100000000, 1);
}
else if(freq == MMC_CLK_200MHZ)
{
ret = clk_get_set_enable(clk_name, 200000000, 1);
}
else
{
dprintf(CRITICAL, "sdc frequency (%d) is not supported\n", freq);
ASSERT(0);
}
if(ret)
{
dprintf(CRITICAL, "failed to set sdc1_core_clk ret = %d\n", ret);
ASSERT(0);
}
/* Enalbe MCI clock */
#ifndef MMC_SDHCI_SUPPORT
mmc_boot_mci_clk_enable();
#endif
}
/* Configure UART clock based on the UART block id*/
void clock_config_uart_dm(uint8_t id)
{
int ret;
ret = clk_get_set_enable("uart2_iface_clk", 0, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set uart2_iface_clk ret = %d\n", ret);
ASSERT(0);
}
ret = clk_get_set_enable("uart2_core_clk", 7372800, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set uart1_core_clk ret = %d\n", ret);
ASSERT(0);
}
}
/* Function to asynchronously reset CE.
* Function assumes that all the CE clocks are off.
*/
static void ce_async_reset(uint8_t instance)
{
if (instance == 1)
{
/* TODO: Add support for instance 1. */
dprintf(CRITICAL, "CE instance not supported instance = %d", instance);
ASSERT(0);
}
else if (instance == 2)
{
/* Start the block reset for CE */
writel(1, GCC_CE2_BCR);
udelay(2);
/* Take CE block out of reset */
writel(0, GCC_CE2_BCR);
udelay(2);
}
else
{
dprintf(CRITICAL, "CE instance not supported instance = %d", instance);
ASSERT(0);
}
}
void clock_ce_enable(uint8_t instance)
{
int ret;
char clk_name[64];
snprintf(clk_name, 64, "ce%u_src_clk", instance);
ret = clk_get_set_enable(clk_name, 100000000, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set ce_src_clk ret = %d\n", ret);
ASSERT(0);
}
snprintf(clk_name, 64, "ce%u_core_clk", instance);
ret = clk_get_set_enable(clk_name, 0, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set ce_core_clk ret = %d\n", ret);
ASSERT(0);
}
snprintf(clk_name, 64, "ce%u_ahb_clk", instance);
ret = clk_get_set_enable(clk_name, 0, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set ce_ahb_clk ret = %d\n", ret);
ASSERT(0);
}
snprintf(clk_name, 64, "ce%u_axi_clk", instance);
ret = clk_get_set_enable(clk_name, 0, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set ce_axi_clk ret = %d\n", ret);
ASSERT(0);
}
/* Wait for 48 * #pipes cycles.
* This is necessary as immediately after an access control reset (boot up)
* or a debug re-enable, the Crypto core sequentially clears its internal
* pipe key storage memory. If pipe key initialization writes are attempted
* during this time, they may be overwritten by the internal clearing logic.
*/
udelay(1);
}
void clock_ce_disable(uint8_t instance)
{
struct clk *ahb_clk;
struct clk *cclk;
struct clk *axi_clk;
struct clk *src_clk;
char clk_name[64];
snprintf(clk_name, 64, "ce%u_src_clk", instance);
src_clk = clk_get(clk_name);
snprintf(clk_name, 64, "ce%u_ahb_clk", instance);
ahb_clk = clk_get(clk_name);
snprintf(clk_name, 64, "ce%u_axi_clk", instance);
axi_clk = clk_get(clk_name);
snprintf(clk_name, 64, "ce%u_core_clk", instance);
cclk = clk_get(clk_name);
clk_disable(ahb_clk);
clk_disable(axi_clk);
clk_disable(cclk);
clk_disable(src_clk);
/* Some delay for the clocks to stabalize. */
udelay(1);
}
void clock_config_ce(uint8_t instance)
{
/* Need to enable the clock before disabling since the clk_disable()
* has a check to default to nop when the clk_enable() is not called
* on that particular clock.
*/
clock_ce_enable(instance);
clock_ce_disable(instance);
ce_async_reset(instance);
clock_ce_enable(instance);
}
void clock_config_blsp_i2c(uint8_t blsp_id, uint8_t qup_id)
{
uint8_t ret = 0;
char clk_name[64];
struct clk *qup_clk;
snprintf(clk_name, 64, "blsp%u_ahb_clk", blsp_id);
ret = clk_get_set_enable(clk_name, 0 , 1);
if (ret) {
dprintf(CRITICAL, "Failed to enable %s clock\n", clk_name);
return;
}
snprintf(clk_name, 64, "blsp%u_qup%u_i2c_apps_clk", blsp_id,
(qup_id + 1));
qup_clk = clk_get(clk_name);
if (!qup_clk) {
dprintf(CRITICAL, "Failed to get %s\n", clk_name);
return;
}
ret = clk_enable(qup_clk);
if (ret) {
dprintf(CRITICAL, "Failed to enable %s\n", clk_name);
return;
}
}
void mdp_gdsc_ctrl(uint8_t enable)
{
uint32_t reg = 0;
reg = readl(MDP_GDSCR);
if (enable) {
if (reg & 0x1) {
reg &= ~(BIT(0) | GDSC_EN_FEW_WAIT_MASK);
reg |= GDSC_EN_FEW_WAIT_256_MASK;
writel(reg, MDP_GDSCR);
}
while(readl(MDP_GDSCR) & ((GDSC_POWER_ON_BIT) | (GDSC_POWER_ON_STATUS_BIT)));
} else {
reg &= ~BIT(0);
writel(reg, MDP_GDSCR);
while(!(readl(MDP_GDSCR) & ((GDSC_POWER_ON_BIT))));
}
}
/* Configure MDP clock */
void mdp_clock_init(void)
{
int ret;
/* Set MDP clock to 200MHz */
ret = clk_get_set_enable("mdp_ahb_clk", 0, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set mdp_ahb_clk ret = %d\n", ret);
ASSERT(0);
}
ret = clk_get_set_enable("mdss_mdp_clk_src", 75000000, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set mdp_clk_src ret = %d\n", ret);
ASSERT(0);
}
ret = clk_get_set_enable("mdss_vsync_clk", 0, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set mdss vsync clk ret = %d\n", ret);
ASSERT(0);
}
ret = clk_get_set_enable("mdss_mdp_clk", 0, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set mdp_clk ret = %d\n", ret);
ASSERT(0);
}
ret = clk_get_set_enable("mdss_mdp_lut_clk", 0, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set lut_mdp clk ret = %d\n", ret);
ASSERT(0);
}
}
void mdp_clock_disable(void)
{
writel(0x0, DSI_BYTE0_CBCR);
writel(0x0, DSI_PIXEL0_CBCR);
clk_disable(clk_get("mdss_vsync_clk"));
clk_disable(clk_get("mdss_mdp_clk"));
clk_disable(clk_get("mdss_mdp_lut_clk"));
clk_disable(clk_get("mdss_mdp_clk_src"));
clk_disable(clk_get("mdp_ahb_clk"));
}
/* Initialize all clocks needed by Display */
void mmss_clock_init(uint32_t dsi_pixel0_cfg_rcgr)
{
int ret;
/* Configure Byte clock */
writel(0x100, DSI_BYTE0_CFG_RCGR);
writel(0x1, DSI_BYTE0_CMD_RCGR);
writel(0x1, DSI_BYTE0_CBCR);
/* Configure ESC clock */
ret = clk_get_set_enable("mdss_esc0_clk", 0, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set esc0_clk ret = %d\n", ret);
ASSERT(0);
}
/* Configure MMSSNOC AXI clock */
ret = clk_get_set_enable("mmss_mmssnoc_axi_clk", 100000000, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set mmssnoc_axi_clk ret = %d\n", ret);
ASSERT(0);
}
/* Configure MMSSNOC AXI clock */
ret = clk_get_set_enable("mmss_s0_axi_clk", 100000000, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set mmss_s0_axi_clk ret = %d\n", ret);
ASSERT(0);
}
/* Configure AXI clock */
ret = clk_get_set_enable("mdss_axi_clk", 100000000, 1);
if(ret)
{
dprintf(CRITICAL, "failed to set mdss_axi_clk ret = %d\n", ret);
ASSERT(0);
}
/* Configure Pixel clock */
writel(dsi_pixel0_cfg_rcgr, DSI_PIXEL0_CFG_RCGR);
writel(0x1, DSI_PIXEL0_CMD_RCGR);
writel(0x1, DSI_PIXEL0_CBCR);
}
void mmss_clock_disable(void)
{
/* Disable ESC clock */
clk_disable(clk_get("mdss_esc0_clk"));
/* Disable MDSS AXI clock */
clk_disable(clk_get("mdss_axi_clk"));
/* Disable MMSSNOC S0AXI clock */
clk_disable(clk_get("mmss_s0_axi_clk"));
/* Disable MMSSNOC AXI clock */
clk_disable(clk_get("mmss_mmssnoc_axi_clk"));
}
@@ -0,0 +1,91 @@
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <debug.h>
#include <reg.h>
#include <platform/iomap.h>
#include <platform/gpio.h>
#include <gsbi.h>
#include <blsp_qup.h>
void gpio_tlmm_config(uint32_t gpio, uint8_t func,
uint8_t dir, uint8_t pull,
uint8_t drvstr, uint32_t enable)
{
uint32_t val = 0;
val |= pull;
val |= func << 2;
val |= drvstr << 6;
val |= enable << 9;
writel(val, (unsigned int *)GPIO_CONFIG_ADDR(gpio));
return;
}
void gpio_set(uint32_t gpio, uint32_t dir)
{
writel(dir, (unsigned int *)GPIO_IN_OUT_ADDR(gpio));
return;
}
/* Configure gpio for blsp uart 2 */
void gpio_config_uart_dm(uint8_t id)
{
/* configure rx gpio */
gpio_tlmm_config(5, 2, GPIO_INPUT, GPIO_NO_PULL,
GPIO_8MA, GPIO_DISABLE);
/* configure tx gpio */
gpio_tlmm_config(4, 2, GPIO_OUTPUT, GPIO_NO_PULL,
GPIO_8MA, GPIO_DISABLE);
}
void gpio_config_blsp_i2c(uint8_t blsp_id, uint8_t qup_id)
{
if (blsp_id == BLSP_ID_2) {
switch (qup_id) {
case QUP_ID_4:
gpio_tlmm_config(83, 3, GPIO_OUTPUT, GPIO_NO_PULL,
GPIO_6MA, GPIO_DISABLE);
gpio_tlmm_config(84, 3, GPIO_OUTPUT, GPIO_NO_PULL,
GPIO_6MA, GPIO_DISABLE);
break;
default:
dprintf(CRITICAL, "Configure gpios for QUP instance: %u\n",
qup_id);
ASSERT(0);
};
}
else if (blsp_id == BLSP_ID_1) {
switch (qup_id) {
default:
dprintf(CRITICAL, "Configure gpios for QUP instance: %u\n",
qup_id);
ASSERT(0);
};
}
}
@@ -0,0 +1,86 @@
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __COPPER_CLOCK_H
#define __COPPER_CLOCK_H
#include <clock.h>
#include <clock_lib2.h>
#define UART_DM_CLK_RX_TX_BIT_RATE 0xCC
#define REG_MM(off) (MSM_MMSS_CLK_CTL_BASE + (off))
#define MDP_GDSCR REG_MM(0x2304)
#define GDSC_POWER_ON_BIT BIT(31)
#define GDSC_POWER_ON_STATUS_BIT BIT(29)
#define GDSC_EN_FEW_WAIT_MASK (0x0F << 16)
#define GDSC_EN_FEW_WAIT_256_MASK BIT(19)
#define VSYNC_CMD_RCGR REG_MM(0x2080)
#define VSYNC_CFG_RCGR REG_MM(0x2084)
#define MDSS_VSYNC_CBCR REG_MM(0x2328)
#define MDP_CMD_RCGR REG_MM(0x2040)
#define MDP_CFG_RCGR REG_MM(0x2044)
#define MDP_CBCR REG_MM(0x231C)
#define MDP_LUT_CBCR REG_MM(0x2320)
#define MDP_AHB_CBCR REG_MM(0x2308)
#define MDP_AXI_CMD_RCGR REG_MM(0x5040)
#define MDP_AXI_CFG_RCGR REG_MM(0x5044)
#define MDP_AXI_CBCR REG_MM(0x2310)
#define MMSS_S0_AXI_CBCR REG_MM(0x5064)
#define MMSS_MMSSNOC_AXI_CBCR REG_MM(0x506C)
#define DSI_BYTE0_CMD_RCGR REG_MM(0x2120)
#define DSI_BYTE0_CFG_RCGR REG_MM(0x2124)
#define DSI_BYTE0_CBCR REG_MM(0x233C)
#define DSI_ESC0_CMD_RCGR REG_MM(0x2160)
#define DSI_ESC0_CFG_RCGR REG_MM(0x2164)
#define DSI_ESC0_CBCR REG_MM(0x2344)
#define DSI_PIXEL0_CMD_RCGR REG_MM(0x2000)
#define DSI_PIXEL0_CFG_RCGR REG_MM(0x2004)
#define DSI_PIXEL0_CBCR REG_MM(0x2314)
#define DSI0_PHY_PLL_OUT BIT(8)
#define PIXEL_SRC_DIV_1_5 BIT(1)
void platform_clock_init(void);
void clock_init_mmc(uint32_t interface);
void clock_config_mmc(uint32_t interface, uint32_t freq);
void clock_config_uart_dm(uint8_t id);
void hsusb_clock_init(void);
void clock_config_ce(uint8_t instance);
void mdp_clock_init(void);
void mdp_gdsc_ctrl(uint8_t enable);
void clock_ce_enable(uint8_t instance);
void clock_ce_disable(uint8_t instance);
#endif
@@ -0,0 +1,60 @@
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __PLATFORM_COPPER_GPIO_H
#define __PLATFORM_COPPER_GPIO_H
#include <gpio.h>
/* GPIO TLMM: Direction */
#define GPIO_INPUT 0
#define GPIO_OUTPUT 1
/* GPIO TLMM: Pullup/Pulldown */
#define GPIO_NO_PULL 0
#define GPIO_PULL_DOWN 1
#define GPIO_KEEPER 2
#define GPIO_PULL_UP 3
/* GPIO TLMM: Drive Strength */
#define GPIO_2MA 0
#define GPIO_4MA 1
#define GPIO_6MA 2
#define GPIO_8MA 3
#define GPIO_10MA 4
#define GPIO_12MA 5
#define GPIO_14MA 6
#define GPIO_16MA 7
/* GPIO TLMM: Status */
#define GPIO_ENABLE 0
#define GPIO_DISABLE 1
void gpio_config_uart_dm(uint8_t id);
void gpio_config_blsp_i2c(uint8_t, uint8_t);
#endif
@@ -0,0 +1,182 @@
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _PLATFORM_MSMCOPPER_IOMAP_H_
#define _PLATFORM_MSMCOPPER_IOMAP_H_
#define MSM_IOMAP_BASE 0xF9000000
#define MSM_IOMAP_END 0xFEFFFFFF
#define SDRAM_START_ADDR 0x00000000
#define SDRAM_SEC_BANK_START_ADDR 0x10000000
#define MSM_SHARED_BASE 0x0FA00000
#define RPM_MSG_RAM_BASE 0xFC42B000
#define SYSTEM_IMEM_BASE 0xFE800000
#define MSM_SHARED_IMEM_BASE 0xFE805000
#define RESTART_REASON_ADDR (RPM_MSG_RAM_BASE + 0x65C)
#define RESTART_REASON_ADDR_V2 (MSM_SHARED_IMEM_BASE + 0x65C)
#define FORCE_DLOAD_MODE_ADDR_V2 (MSM_SHARED_IMEM_BASE + 0xFE0)
#define KPSS_BASE 0xF9000000
#define MSM_GIC_DIST_BASE KPSS_BASE
#define MSM_GIC_CPU_BASE (KPSS_BASE + 0x2000)
#define APCS_KPSS_ACS_BASE (KPSS_BASE + 0x00008000)
#define APCS_APC_KPSS_PLL_BASE (KPSS_BASE + 0x0000A000)
#define APCS_KPSS_CFG_BASE (KPSS_BASE + 0x00010000)
#define APCS_KPSS_WDT_BASE (KPSS_BASE + 0x00017000)
#define KPSS_APCS_QTMR_AC_BASE (KPSS_BASE + 0x00020000)
#define KPSS_APCS_F0_QTMR_V1_BASE (KPSS_BASE + 0x00021000)
#define QTMR_BASE KPSS_APCS_F0_QTMR_V1_BASE
#define PERIPH_SS_BASE 0xF9800000
#define MSM_SDC1_BAM_BASE (PERIPH_SS_BASE + 0x00004000)
#define MSM_SDC1_BASE (PERIPH_SS_BASE + 0x00024000)
#define MSM_SDC1_DML_BASE (PERIPH_SS_BASE + 0x00024800)
#define MSM_SDC1_SDHCI_BASE (PERIPH_SS_BASE + 0x00024900)
#define MSM_SDC3_BAM_BASE (PERIPH_SS_BASE + 0x00044000)
#define MSM_SDC3_BASE (PERIPH_SS_BASE + 0x00064000)
#define MSM_SDC3_DML_BASE (PERIPH_SS_BASE + 0x00064800)
#define MSM_SDC3_SDHCI_BASE (PERIPH_SS_BASE + 0x00064900)
#define MSM_SDC2_BAM_BASE (PERIPH_SS_BASE + 0x00084000)
#define MSM_SDC2_BASE (PERIPH_SS_BASE + 0x000A4000)
#define MSM_SDC2_DML_BASE (PERIPH_SS_BASE + 0x000A4800)
#define MSM_SDC2_SDHCI_BASE (PERIPH_SS_BASE + 0x000A4900)
#define MSM_SDC4_BAM_BASE (PERIPH_SS_BASE + 0x000C4000)
#define MSM_SDC4_BASE (PERIPH_SS_BASE + 0x000E4000)
#define MSM_SDC4_DML_BASE (PERIPH_SS_BASE + 0x000E4800)
#define MSM_SDC4_SDHCI_BASE (PERIPH_SS_BASE + 0x000E4900)
#define BLSP1_UART0_BASE (PERIPH_SS_BASE + 0x0011D000)
#define BLSP1_UART1_BASE (PERIPH_SS_BASE + 0x0011E000)
#define BLSP1_UART2_BASE (PERIPH_SS_BASE + 0x0011F000)
#define BLSP1_UART3_BASE (PERIPH_SS_BASE + 0x00120000)
#define BLSP1_UART4_BASE (PERIPH_SS_BASE + 0x00121000)
#define BLSP1_UART5_BASE (PERIPH_SS_BASE + 0x00122000)
#define MSM_USB_BASE (PERIPH_SS_BASE + 0x00255000)
#define CLK_CTL_BASE 0xFC400000
#define GCC_WDOG_DEBUG (CLK_CTL_BASE + 0x00001780)
#define USB_HS_BCR (CLK_CTL_BASE + 0x480)
#define SPMI_BASE 0xFC4C0000
#define SPMI_GENI_BASE (SPMI_BASE + 0xA000)
#define SPMI_PIC_BASE (SPMI_BASE + 0xB000)
#define MSM_CE2_BAM_BASE 0xFD444000
#define MSM_CE2_BASE 0xFD45A000
#define USB2_PHY_SEL 0xFD4AB000
#define TLMM_BASE_ADDR 0xFD510000
#define GPIO_CONFIG_ADDR(x) (TLMM_BASE_ADDR + 0x1000 + (x)*0x10)
#define GPIO_IN_OUT_ADDR(x) (TLMM_BASE_ADDR + 0x1004 + (x)*0x10)
#define MPM2_MPM_CTRL_BASE 0xFC4A1000
#define MPM2_MPM_PS_HOLD 0xFC4AB000
#define MPM2_MPM_SLEEP_TIMETICK_COUNT_VAL 0xFC4A3000
/* CE 1 */
#define GCC_CE1_BCR (CLK_CTL_BASE + 0x1040)
#define GCC_CE1_CMD_RCGR (CLK_CTL_BASE + 0x1050)
#define GCC_CE1_CFG_RCGR (CLK_CTL_BASE + 0x1054)
#define GCC_CE1_CBCR (CLK_CTL_BASE + 0x1044)
#define GCC_CE1_AXI_CBCR (CLK_CTL_BASE + 0x1048)
#define GCC_CE1_AHB_CBCR (CLK_CTL_BASE + 0x104C)
/* CE 2 */
#define GCC_CE2_BCR (CLK_CTL_BASE + 0x1080)
#define GCC_CE2_CMD_RCGR (CLK_CTL_BASE + 0x1090)
#define GCC_CE2_CFG_RCGR (CLK_CTL_BASE + 0x1094)
#define GCC_CE2_CBCR (CLK_CTL_BASE + 0x1084)
#define GCC_CE2_AXI_CBCR (CLK_CTL_BASE + 0x1088)
#define GCC_CE2_AHB_CBCR (CLK_CTL_BASE + 0x108C)
/* GPLL */
#define GPLL0_STATUS (CLK_CTL_BASE + 0x001C)
#define APCS_GPLL_ENA_VOTE (CLK_CTL_BASE + 0x1480)
#define APCS_CLOCK_BRANCH_ENA_VOTE (CLK_CTL_BASE + 0x1484)
/* SDCC */
#define SDCC1_BCR (CLK_CTL_BASE + 0x4C0) /* block reset */
#define SDCC1_APPS_CBCR (CLK_CTL_BASE + 0x4C4) /* branch control */
#define SDCC1_AHB_CBCR (CLK_CTL_BASE + 0x4C8)
#define SDCC1_INACTIVITY_TIMER_CBCR (CLK_CTL_BASE + 0x4CC)
#define SDCC1_CMD_RCGR (CLK_CTL_BASE + 0x4D0) /* cmd */
#define SDCC1_CFG_RCGR (CLK_CTL_BASE + 0x4D4) /* cfg */
#define SDCC1_M (CLK_CTL_BASE + 0x4D8) /* m */
#define SDCC1_N (CLK_CTL_BASE + 0x4DC) /* n */
#define SDCC1_D (CLK_CTL_BASE + 0x4E0) /* d */
/* UART */
#define BLSP1_AHB_CBCR (CLK_CTL_BASE + 0x5C4)
#define BLSP2_AHB_CBCR (CLK_CTL_BASE + 0x944)
#define BLSP1_UART2_APPS_CBCR (CLK_CTL_BASE + 0x704)
#define BLSP1_UART2_APPS_CMD_RCGR (CLK_CTL_BASE + 0x70C)
#define BLSP1_UART2_APPS_CFG_RCGR (CLK_CTL_BASE + 0x710)
#define BLSP1_UART2_APPS_M (CLK_CTL_BASE + 0x714)
#define BLSP1_UART2_APPS_N (CLK_CTL_BASE + 0x718)
#define BLSP1_UART2_APPS_D (CLK_CTL_BASE + 0x71C)
/* USB */
#define USB_HS_SYSTEM_CBCR (CLK_CTL_BASE + 0x484)
#define USB_HS_AHB_CBCR (CLK_CTL_BASE + 0x488)
#define USB_HS_SYSTEM_CMD_RCGR (CLK_CTL_BASE + 0x490)
#define USB_HS_SYSTEM_CFG_RCGR (CLK_CTL_BASE + 0x494)
/* I2C */
#define BLSP2_QUP5_I2C_APPS_CBCR (CLK_CTL_BASE + 0xB88)
#define BLSP_QUP_BASE(blsp_id, qup_id) ((blsp_id == 1) ? \
(PERIPH_SS_BASE + 0x00123000 \
+ (qup_id * 0x1000)) :\
(PERIPH_SS_BASE + 0x00163000 + \
(qup_id * 0x1000)))
#define MSM_MMSS_CLK_CTL_BASE 0xFD8C0000
#define MIPI_DSI_BASE (0xFD922800)
#define REG_DSI(off) (MIPI_DSI_BASE + 0x04 + (off))
#define MDP_BASE (0xfd900000)
#define REG_MDP(off) (MDP_BASE + (off))
/* DRV strength for sdcc */
#define SDC1_HDRV_PULL_CTL (TLMM_BASE_ADDR + 0x00002044)
/* SDHCI */
#define SDCC_MCI_HC_MODE (PERIPH_SS_BASE + 0x00024078)
#define SDCC_HC_PWRCTL_MASK_REG (PERIPH_SS_BASE + 0x000240E0)
#define SDCC_HC_PWRCTL_CTL_REG (PERIPH_SS_BASE + 0x000240E8)
#endif
@@ -0,0 +1,70 @@
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, Inc. nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __IRQS_COPPER_H
#define __IRQS_COPPER_H
/* MSM ACPU Interrupt Numbers */
/* 0-15: STI/SGI (software triggered/generated interrupts)
* 16-31: PPI (private peripheral interrupts)
* 32+: SPI (shared peripheral interrupts)
*/
#define GIC_PPI_START 16
#define GIC_SPI_START 32
#define INT_QTMR_NON_SECURE_PHY_TIMER_EXP (GIC_PPI_START + 3)
#define INT_QTMR_VIRTUAL_TIMER_EXP (GIC_PPI_START + 4)
#define INT_QTMR_FRM_0_PHYSICAL_TIMER_EXP (GIC_SPI_START + 8)
#define USB1_HS_BAM_IRQ (GIC_SPI_START + 135)
#define USB1_HS_IRQ (GIC_SPI_START + 134)
#define USB2_IRQ (GIC_SPI_START + 141)
#define USB1_IRQ (GIC_SPI_START + 142)
/* Retrofit universal macro names */
#define INT_USB_HS USB1_HS_IRQ
#define EE0_KRAIT_HLOS_SPMI_PERIPH_IRQ (GIC_SPI_START + 190)
#define NR_MSM_IRQS 256
#define NR_GPIO_IRQS 173
#define NR_BOARD_IRQS 0
#define NR_IRQS (NR_MSM_IRQS + NR_GPIO_IRQS + \
NR_BOARD_IRQS)
#define BLSP_QUP_IRQ(blsp_id, qup_id) ((blsp_id == 1) ? \
((GIC_SPI_START + 95) + qup_id):\
((GIC_SPI_START + 101) + qup_id))
#define SDCC_PWRCTRL_IRQ (GIC_SPI_START + 138)
#endif /* __IRQS_COPPER_H */
@@ -0,0 +1,599 @@
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <assert.h>
#include <reg.h>
#include <err.h>
#include <clock.h>
#include <clock_pll.h>
#include <clock_lib2.h>
#include <platform/clock.h>
#include <platform/iomap.h>
/* Mux source select values */
#define cxo_source_val 0
#define gpll0_source_val 1
#define cxo_mm_source_val 0
#define mmpll0_mm_source_val 1
#define mmpll1_mm_source_val 2
#define mmpll3_mm_source_val 3
#define gpll0_mm_source_val 5
struct clk_freq_tbl rcg_dummy_freq = F_END;
/* Clock Operations */
static struct clk_ops clk_ops_branch =
{
.enable = clock_lib2_branch_clk_enable,
.disable = clock_lib2_branch_clk_disable,
.set_rate = clock_lib2_branch_set_rate,
};
static struct clk_ops clk_ops_rcg_mnd =
{
.enable = clock_lib2_rcg_enable,
.set_rate = clock_lib2_rcg_set_rate,
};
static struct clk_ops clk_ops_rcg =
{
.enable = clock_lib2_rcg_enable,
.set_rate = clock_lib2_rcg_set_rate,
};
static struct clk_ops clk_ops_cxo =
{
.enable = cxo_clk_enable,
.disable = cxo_clk_disable,
};
static struct clk_ops clk_ops_pll_vote =
{
.enable = pll_vote_clk_enable,
.disable = pll_vote_clk_disable,
.auto_off = pll_vote_clk_disable,
.is_enabled = pll_vote_clk_is_enabled,
};
static struct clk_ops clk_ops_vote =
{
.enable = clock_lib2_vote_clk_enable,
.disable = clock_lib2_vote_clk_disable,
};
/* Clock Sources */
static struct fixed_clk cxo_clk_src =
{
.c = {
.rate = 19200000,
.dbg_name = "cxo_clk_src",
.ops = &clk_ops_cxo,
},
};
static struct pll_vote_clk gpll0_clk_src =
{
.en_reg = (void *) APCS_GPLL_ENA_VOTE,
.en_mask = BIT(0),
.status_reg = (void *) GPLL0_STATUS,
.status_mask = BIT(17),
.parent = &cxo_clk_src.c,
.c = {
.rate = 600000000,
.dbg_name = "gpll0_clk_src",
.ops = &clk_ops_pll_vote,
},
};
/* SDCC Clocks */
static struct clk_freq_tbl ftbl_gcc_sdcc1_2_apps_clk[] =
{
F( 144000, cxo, 16, 3, 25),
F( 400000, cxo, 12, 1, 4),
F( 20000000, gpll0, 15, 1, 2),
F( 25000000, gpll0, 12, 1, 2),
F( 50000000, gpll0, 12, 0, 0),
F(100000000, gpll0, 6, 0, 0),
F(200000000, gpll0, 3, 0, 0),
F_END
};
static struct rcg_clk sdcc1_apps_clk_src =
{
.cmd_reg = (uint32_t *) SDCC1_CMD_RCGR,
.cfg_reg = (uint32_t *) SDCC1_CFG_RCGR,
.m_reg = (uint32_t *) SDCC1_M,
.n_reg = (uint32_t *) SDCC1_N,
.d_reg = (uint32_t *) SDCC1_D,
.set_rate = clock_lib2_rcg_set_rate_mnd,
.freq_tbl = ftbl_gcc_sdcc1_2_apps_clk,
.current_freq = &rcg_dummy_freq,
.c = {
.dbg_name = "sdc1_clk",
.ops = &clk_ops_rcg_mnd,
},
};
static struct branch_clk gcc_sdcc1_apps_clk =
{
.cbcr_reg = (uint32_t *) SDCC1_APPS_CBCR,
.parent = &sdcc1_apps_clk_src.c,
.c = {
.dbg_name = "gcc_sdcc1_apps_clk",
.ops = &clk_ops_branch,
},
};
static struct branch_clk gcc_sdcc1_ahb_clk =
{
.cbcr_reg = (uint32_t *) SDCC1_AHB_CBCR,
.has_sibling = 1,
.c = {
.dbg_name = "gcc_sdcc1_ahb_clk",
.ops = &clk_ops_branch,
},
};
/* UART Clocks */
static struct clk_freq_tbl ftbl_gcc_blsp1_2_uart1_6_apps_clk[] =
{
F( 3686400, gpll0, 1, 96, 15625),
F( 7372800, gpll0, 1, 192, 15625),
F(14745600, gpll0, 1, 384, 15625),
F(16000000, gpll0, 5, 2, 15),
F(19200000, cxo, 1, 0, 0),
F(24000000, gpll0, 5, 1, 5),
F(32000000, gpll0, 1, 4, 75),
F(40000000, gpll0, 15, 0, 0),
F(46400000, gpll0, 1, 29, 375),
F(48000000, gpll0, 12.5, 0, 0),
F(51200000, gpll0, 1, 32, 375),
F(56000000, gpll0, 1, 7, 75),
F(58982400, gpll0, 1, 1536, 15625),
F(60000000, gpll0, 10, 0, 0),
F_END
};
static struct rcg_clk blsp1_uart2_apps_clk_src =
{
.cmd_reg = (uint32_t *) BLSP1_UART2_APPS_CMD_RCGR,
.cfg_reg = (uint32_t *) BLSP1_UART2_APPS_CFG_RCGR,
.m_reg = (uint32_t *) BLSP1_UART2_APPS_M,
.n_reg = (uint32_t *) BLSP1_UART2_APPS_N,
.d_reg = (uint32_t *) BLSP1_UART2_APPS_D,
.set_rate = clock_lib2_rcg_set_rate_mnd,
.freq_tbl = ftbl_gcc_blsp1_2_uart1_6_apps_clk,
.current_freq = &rcg_dummy_freq,
.c = {
.dbg_name = "blsp1_uart2_apps_clk",
.ops = &clk_ops_rcg_mnd,
},
};
static struct branch_clk gcc_blsp1_uart2_apps_clk =
{
.cbcr_reg = (uint32_t *) BLSP1_UART2_APPS_CBCR,
.parent = &blsp1_uart2_apps_clk_src.c,
.c = {
.dbg_name = "gcc_blsp1_uart2_apps_clk",
.ops = &clk_ops_branch,
},
};
static struct vote_clk gcc_blsp1_ahb_clk = {
.cbcr_reg = (uint32_t *) BLSP1_AHB_CBCR,
.vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
.en_mask = BIT(17),
.c = {
.dbg_name = "gcc_blsp1_ahb_clk",
.ops = &clk_ops_vote,
},
};
static struct vote_clk gcc_blsp2_ahb_clk = {
.cbcr_reg = (uint32_t *) BLSP2_AHB_CBCR,
.vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
.en_mask = BIT(15),
.c = {
.dbg_name = "gcc_blsp2_ahb_clk",
.ops = &clk_ops_vote,
},
};
/* USB Clocks */
static struct clk_freq_tbl ftbl_gcc_usb_hs_system_clk[] =
{
F(75000000, gpll0, 8, 0, 0),
F_END
};
static struct rcg_clk usb_hs_system_clk_src =
{
.cmd_reg = (uint32_t *) USB_HS_SYSTEM_CMD_RCGR,
.cfg_reg = (uint32_t *) USB_HS_SYSTEM_CFG_RCGR,
.set_rate = clock_lib2_rcg_set_rate_hid,
.freq_tbl = ftbl_gcc_usb_hs_system_clk,
.current_freq = &rcg_dummy_freq,
.c = {
.dbg_name = "usb_hs_system_clk",
.ops = &clk_ops_rcg,
},
};
static struct branch_clk gcc_usb_hs_system_clk =
{
.cbcr_reg = (uint32_t *) USB_HS_SYSTEM_CBCR,
.parent = &usb_hs_system_clk_src.c,
.c = {
.dbg_name = "gcc_usb_hs_system_clk",
.ops = &clk_ops_branch,
},
};
static struct branch_clk gcc_usb_hs_ahb_clk =
{
.cbcr_reg = (uint32_t *) USB_HS_AHB_CBCR,
.has_sibling = 1,
.c = {
.dbg_name = "gcc_usb_hs_ahb_clk",
.ops = &clk_ops_branch,
},
};
/* CE Clocks */
static struct clk_freq_tbl ftbl_gcc_ce2_clk[] = {
F( 50000000, gpll0, 12, 0, 0),
F(100000000, gpll0, 6, 0, 0),
F_END
};
static struct rcg_clk ce2_clk_src = {
.cmd_reg = (uint32_t *) GCC_CE2_CMD_RCGR,
.cfg_reg = (uint32_t *) GCC_CE2_CFG_RCGR,
.set_rate = clock_lib2_rcg_set_rate_hid,
.freq_tbl = ftbl_gcc_ce2_clk,
.current_freq = &rcg_dummy_freq,
.c = {
.dbg_name = "ce2_clk_src",
.ops = &clk_ops_rcg,
},
};
static struct vote_clk gcc_ce2_clk = {
.cbcr_reg = (uint32_t *) GCC_CE2_CBCR,
.vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
.en_mask = BIT(2),
.c = {
.dbg_name = "gcc_ce2_clk",
.ops = &clk_ops_vote,
},
};
static struct vote_clk gcc_ce2_ahb_clk = {
.cbcr_reg = (uint32_t *) GCC_CE2_AHB_CBCR,
.vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
.en_mask = BIT(0),
.c = {
.dbg_name = "gcc_ce2_ahb_clk",
.ops = &clk_ops_vote,
},
};
static struct vote_clk gcc_ce2_axi_clk = {
.cbcr_reg = (uint32_t *) GCC_CE2_AXI_CBCR,
.vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
.en_mask = BIT(1),
.c = {
.dbg_name = "gcc_ce2_axi_clk",
.ops = &clk_ops_vote,
},
};
static struct clk_freq_tbl ftbl_gcc_ce1_clk[] = {
F( 50000000, gpll0, 12, 0, 0),
F(100000000, gpll0, 6, 0, 0),
F_END
};
static struct rcg_clk ce1_clk_src = {
.cmd_reg = (uint32_t *) GCC_CE1_CMD_RCGR,
.cfg_reg = (uint32_t *) GCC_CE1_CFG_RCGR,
.set_rate = clock_lib2_rcg_set_rate_hid,
.freq_tbl = ftbl_gcc_ce1_clk,
.current_freq = &rcg_dummy_freq,
.c = {
.dbg_name = "ce1_clk_src",
.ops = &clk_ops_rcg,
},
};
static struct vote_clk gcc_ce1_clk = {
.cbcr_reg = (uint32_t *) GCC_CE1_CBCR,
.vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
.en_mask = BIT(5),
.c = {
.dbg_name = "gcc_ce1_clk",
.ops = &clk_ops_vote,
},
};
static struct vote_clk gcc_ce1_ahb_clk = {
.cbcr_reg = (uint32_t *) GCC_CE1_AHB_CBCR,
.vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
.en_mask = BIT(3),
.c = {
.dbg_name = "gcc_ce1_ahb_clk",
.ops = &clk_ops_vote,
},
};
static struct vote_clk gcc_ce1_axi_clk = {
.cbcr_reg = (uint32_t *) GCC_CE1_AXI_CBCR,
.vote_reg = (uint32_t *) APCS_CLOCK_BRANCH_ENA_VOTE,
.en_mask = BIT(4),
.c = {
.dbg_name = "gcc_ce1_axi_clk",
.ops = &clk_ops_vote,
},
};
struct branch_clk gcc_blsp2_qup5_i2c_apps_clk = {
.cbcr_reg = BLSP2_QUP5_I2C_APPS_CBCR,
.parent = &cxo_clk_src.c,
.c = {
.dbg_name = "gcc_blsp2_qup5_i2c_apps_clk",
.ops = &clk_ops_branch,
},
};
/* Display clocks */
static struct clk_freq_tbl ftbl_mdss_esc0_1_clk[] = {
F_MM(19200000, cxo, 1, 0, 0),
F_END
};
static struct clk_freq_tbl ftbl_mmss_axi_clk[] = {
F_MM(19200000, cxo, 1, 0, 0),
F_MM(100000000, gpll0, 6, 0, 0),
F_END
};
static struct clk_freq_tbl ftbl_mdp_clk[] = {
F_MM( 75000000, gpll0, 8, 0, 0),
F_END
};
static struct rcg_clk dsi_esc0_clk_src = {
.cmd_reg = (uint32_t *) DSI_ESC0_CMD_RCGR,
.cfg_reg = (uint32_t *) DSI_ESC0_CFG_RCGR,
.set_rate = clock_lib2_rcg_set_rate_hid,
.freq_tbl = ftbl_mdss_esc0_1_clk,
.c = {
.dbg_name = "dsi_esc0_clk_src",
.ops = &clk_ops_rcg,
},
};
static struct clk_freq_tbl ftbl_mdss_vsync_clk[] = {
F_MM(19200000, cxo, 1, 0, 0),
F_END
};
static struct rcg_clk vsync_clk_src = {
.cmd_reg = (uint32_t *) VSYNC_CMD_RCGR,
.cfg_reg = (uint32_t *) VSYNC_CFG_RCGR,
.set_rate = clock_lib2_rcg_set_rate_hid,
.freq_tbl = ftbl_mdss_vsync_clk,
.c = {
.dbg_name = "vsync_clk_src",
.ops = &clk_ops_rcg,
},
};
static struct rcg_clk mdp_axi_clk_src = {
.cmd_reg = (uint32_t *) MDP_AXI_CMD_RCGR,
.cfg_reg = (uint32_t *) MDP_AXI_CFG_RCGR,
.set_rate = clock_lib2_rcg_set_rate_hid,
.freq_tbl = ftbl_mmss_axi_clk,
.c = {
.dbg_name = "mdp_axi_clk_src",
.ops = &clk_ops_rcg,
},
};
static struct branch_clk mdss_esc0_clk = {
.cbcr_reg = (uint32_t *) DSI_ESC0_CBCR,
.parent = &dsi_esc0_clk_src.c,
.has_sibling = 0,
.c = {
.dbg_name = "mdss_esc0_clk",
.ops = &clk_ops_branch,
},
};
static struct branch_clk mdss_axi_clk = {
.cbcr_reg = (uint32_t *) MDP_AXI_CBCR,
.parent = &mdp_axi_clk_src.c,
.has_sibling = 0,
.c = {
.dbg_name = "mdss_axi_clk",
.ops = &clk_ops_branch,
},
};
static struct branch_clk mmss_mmssnoc_axi_clk = {
.cbcr_reg = (uint32_t *) MMSS_MMSSNOC_AXI_CBCR,
.parent = &mdp_axi_clk_src.c,
.has_sibling = 0,
.c = {
.dbg_name = "mmss_mmssnoc_axi_clk",
.ops = &clk_ops_branch,
},
};
static struct branch_clk mmss_s0_axi_clk = {
.cbcr_reg = (uint32_t *) MMSS_S0_AXI_CBCR,
.parent = &mdp_axi_clk_src.c,
.has_sibling = 0,
.c = {
.dbg_name = "mmss_s0_axi_clk",
.ops = &clk_ops_branch,
},
};
static struct branch_clk mdp_ahb_clk = {
.cbcr_reg = (uint32_t *) MDP_AHB_CBCR,
.has_sibling = 1,
.c = {
.dbg_name = "mdp_ahb_clk",
.ops = &clk_ops_branch,
},
};
static struct rcg_clk mdss_mdp_clk_src = {
.cmd_reg = (uint32_t *) MDP_CMD_RCGR,
.cfg_reg = (uint32_t *) MDP_CFG_RCGR,
.set_rate = clock_lib2_rcg_set_rate_hid,
.freq_tbl = ftbl_mdp_clk,
.current_freq = &rcg_dummy_freq,
.c = {
.dbg_name = "mdss_mdp_clk_src",
.ops = &clk_ops_rcg,
},
};
static struct branch_clk mdss_mdp_clk = {
.cbcr_reg = (uint32_t *) MDP_CBCR,
.parent = &mdss_mdp_clk_src.c,
.has_sibling = 1,
.c = {
.dbg_name = "mdss_mdp_clk",
.ops = &clk_ops_branch,
},
};
static struct branch_clk mdss_mdp_lut_clk = {
.cbcr_reg = MDP_LUT_CBCR,
.parent = &mdss_mdp_clk_src.c,
.has_sibling = 1,
.c = {
.dbg_name = "mdss_mdp_lut_clk",
.ops = &clk_ops_branch,
},
};
static struct branch_clk mdss_vsync_clk = {
.cbcr_reg = MDSS_VSYNC_CBCR,
.parent = &vsync_clk_src.c,
.has_sibling = 0,
.c = {
.dbg_name = "mdss_vsync_clk",
.ops = &clk_ops_branch,
},
};
/* Clock lookup table */
static struct clk_lookup msm_clocks_8974[] =
{
CLK_LOOKUP("sdc1_iface_clk", gcc_sdcc1_ahb_clk.c),
CLK_LOOKUP("sdc1_core_clk", gcc_sdcc1_apps_clk.c),
CLK_LOOKUP("uart2_iface_clk", gcc_blsp1_ahb_clk.c),
CLK_LOOKUP("uart2_core_clk", gcc_blsp1_uart2_apps_clk.c),
CLK_LOOKUP("usb_iface_clk", gcc_usb_hs_ahb_clk.c),
CLK_LOOKUP("usb_core_clk", gcc_usb_hs_system_clk.c),
CLK_LOOKUP("ce2_ahb_clk", gcc_ce2_ahb_clk.c),
CLK_LOOKUP("ce2_axi_clk", gcc_ce2_axi_clk.c),
CLK_LOOKUP("ce2_core_clk", gcc_ce2_clk.c),
CLK_LOOKUP("ce2_src_clk", ce2_clk_src.c),
CLK_LOOKUP("ce1_ahb_clk", gcc_ce1_ahb_clk.c),
CLK_LOOKUP("ce1_axi_clk", gcc_ce1_axi_clk.c),
CLK_LOOKUP("ce1_core_clk", gcc_ce1_clk.c),
CLK_LOOKUP("ce1_src_clk", ce1_clk_src.c),
CLK_LOOKUP("blsp2_ahb_clk", gcc_blsp2_ahb_clk.c),
CLK_LOOKUP("blsp2_qup5_i2c_apps_clk", gcc_blsp2_qup5_i2c_apps_clk.c),
CLK_LOOKUP("mdp_ahb_clk", mdp_ahb_clk.c),
CLK_LOOKUP("mdss_esc0_clk", mdss_esc0_clk.c),
CLK_LOOKUP("mdss_axi_clk", mdss_axi_clk.c),
CLK_LOOKUP("mmss_mmssnoc_axi_clk", mmss_mmssnoc_axi_clk.c),
CLK_LOOKUP("mmss_s0_axi_clk", mmss_s0_axi_clk.c),
CLK_LOOKUP("mdss_vsync_clk", mdss_vsync_clk.c),
CLK_LOOKUP("mdss_mdp_clk_src", mdss_mdp_clk_src.c),
CLK_LOOKUP("mdss_mdp_clk", mdss_mdp_clk.c),
CLK_LOOKUP("mdss_mdp_lut_clk", mdss_mdp_lut_clk.c),
};
void platform_clock_init(void)
{
clk_init(msm_clocks_8974, ARRAY_SIZE(msm_clocks_8974));
}
@@ -0,0 +1,193 @@
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <debug.h>
#include <reg.h>
#include <platform/iomap.h>
#include <qgic.h>
#include <qtimer.h>
#include <platform/clock.h>
#include <mmu.h>
#include <arch/arm/mmu.h>
#include <smem.h>
#include <board.h>
#include <boot_stats.h>
#define MB (1024*1024)
#define MSM_IOMAP_SIZE ((MSM_IOMAP_END - MSM_IOMAP_BASE)/MB)
/* LK memory - cacheable, write through */
#define LK_MEMORY (MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH | \
MMU_MEMORY_AP_READ_WRITE)
/* Peripherals - non-shared device */
#define IOMAP_MEMORY (MMU_MEMORY_TYPE_DEVICE_SHARED | \
MMU_MEMORY_AP_READ_WRITE | MMU_MEMORY_XN)
/* IMEM memory - cacheable, write through */
#define IMEM_MEMORY (MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH | \
MMU_MEMORY_AP_READ_WRITE | MMU_MEMORY_XN)
static mmu_section_t mmu_section_table[] = {
/* Physical addr, Virtual addr, Size (in MB), Flags */
{MEMBASE, MEMBASE, (MEMSIZE / MB), LK_MEMORY},
{MSM_IOMAP_BASE, MSM_IOMAP_BASE, MSM_IOMAP_SIZE, IOMAP_MEMORY},
/* IMEM needs a seperate entry in the table as it's length is only 0x8000. */
{SYSTEM_IMEM_BASE, SYSTEM_IMEM_BASE, 1, IMEM_MEMORY},
};
static struct smem_ram_ptable ram_ptable;
/* Boot timestamps */
#define BS_INFO_OFFSET (0x6B0)
#define BS_INFO_ADDR_V1 (RPM_MSG_RAM_BASE + BS_INFO_OFFSET)
#define BS_INFO_ADDR_V2 (MSM_SHARED_IMEM_BASE + BS_INFO_OFFSET)
void platform_early_init(void)
{
board_init();
platform_clock_init();
qgic_init();
qtimer_init();
}
void platform_init(void)
{
dprintf(INFO, "platform_init()\n");
}
static uint32_t platform_get_sclk_count(void)
{
return readl(MPM2_MPM_SLEEP_TIMETICK_COUNT_VAL);
}
static uint32_t kernel_load_start;
void bs_set_timestamp(enum bs_entry bs_id)
{
void *bs_imem;
uint32_t soc_ver = board_soc_version();
if (bs_id >= BS_MAX) {
dprintf(CRITICAL, "bad bs id: %u, max: %u\n", bs_id, BS_MAX);
ASSERT(0);
}
if (bs_id == BS_KERNEL_LOAD_START) {
kernel_load_start = platform_get_sclk_count();
return;
}
if (soc_ver < BOARD_SOC_VERSION2)
bs_imem = (void *)BS_INFO_ADDR_V1;
else
bs_imem = (void *)BS_INFO_ADDR_V2;
if(bs_id == BS_KERNEL_LOAD_DONE)
writel(platform_get_sclk_count() - kernel_load_start,
bs_imem + (sizeof(uint32_t) * BS_KERNEL_LOAD_TIME));
else
writel(platform_get_sclk_count(),
bs_imem + (sizeof(uint32_t) * bs_id));
}
void platform_uninit(void)
{
#if DISPLAY_SPLASH_SCREEN
display_shutdown();
#endif
qtimer_uninit();
}
int platform_use_identity_mmu_mappings(void)
{
/* Use only the mappings specified in this file. */
return 0;
}
addr_t platform_get_virt_to_phys_mapping(addr_t virt_addr)
{
/* Return same address as we are using 1-1 mapping. */
return virt_addr;
}
addr_t platform_get_phys_to_virt_mapping(addr_t phys_addr)
{
/* Return same address as we are using 1-1 mapping. */
return phys_addr;
}
/* Setup memory for this platform */
void platform_init_mmu_mappings(void)
{
uint32_t i;
uint32_t sections;
uint32_t table_size = ARRAY_SIZE(mmu_section_table);
ASSERT(smem_ram_ptable_init(&ram_ptable));
/* Configure the MMU page entries for SDRAM and IMEM memory read
from the smem ram table*/
for(i = 0; i < ram_ptable.len; i++)
{
if(ram_ptable.parts[i].type == SYS_MEMORY)
{
if((ram_ptable.parts[i].category == SDRAM) ||
(ram_ptable.parts[i].category == IMEM))
{
/* Check to ensure that start address is 1MB aligned */
ASSERT((ram_ptable.parts[i].start & 0xFFFFF) == 0);
sections = (ram_ptable.parts[i].size) / MB;
while(sections--) {
arm_mmu_map_section(ram_ptable.parts[i].start +
sections * MB,
ram_ptable.parts[i].start +
sections * MB,
(MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH | \
MMU_MEMORY_AP_READ_WRITE | MMU_MEMORY_XN));
}
}
}
}
/* Configure the MMU page entries for memory read from the
mmu_section_table */
for (i = 0; i < table_size; i++) {
sections = mmu_section_table[i].num_of_sections;
while (sections--) {
arm_mmu_map_section(mmu_section_table[i].paddress +
sections * MB,
mmu_section_table[i].vaddress +
sections * MB,
mmu_section_table[i].flags);
}
}
}
@@ -0,0 +1,29 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
ARCH := arm
ARM_CPU := cortex-a8
CPU := generic
DEFINES += ARM_CPU_CORE_KRAIT
MMC_SLOT := 1
DEFINES += PERIPH_BLK_BLSP=1
DEFINES += WITH_CPU_EARLY_INIT=0 WITH_CPU_WARM_BOOT=0 \
MMC_SLOT=$(MMC_SLOT) SSD_ENABLE
DEFINES += TZ_SAVE_KERNEL_HASH
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared/include
DEVS += fbcon
MODULES += dev/fbcon
OBJS += \
$(LOCAL_DIR)/platform.o \
$(LOCAL_DIR)/acpuclock.o \
$(LOCAL_DIR)/msm8974-clock.o \
$(LOCAL_DIR)/gpio.o
LINKER_SCRIPT += $(BUILDDIR)/system-onesegment.ld
include platform/msm_shared/rules.mk