2014-11-22 00:33:26 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. 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.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 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.
|
|
|
|
*/
|
|
|
|
|
2019-03-03 07:01:05 +01:00
|
|
|
#include <device/mmio.h>
|
2015-02-19 12:13:26 +01:00
|
|
|
#include <soc/iomap.h>
|
2014-12-06 19:44:58 +01:00
|
|
|
#include <soc/gsbi.h>
|
2015-02-19 12:13:26 +01:00
|
|
|
#include <console/console.h>
|
2014-11-22 00:33:26 +01:00
|
|
|
|
2015-02-19 12:13:26 +01:00
|
|
|
static inline void *gsbi_ctl_reg_addr(gsbi_id_t gsbi_id)
|
|
|
|
{
|
|
|
|
switch (gsbi_id) {
|
|
|
|
case GSBI_ID_1:
|
|
|
|
return GSBI1_CTL_REG;
|
|
|
|
case GSBI_ID_2:
|
|
|
|
return GSBI2_CTL_REG;
|
|
|
|
case GSBI_ID_3:
|
|
|
|
return GSBI3_CTL_REG;
|
|
|
|
case GSBI_ID_4:
|
|
|
|
return GSBI4_CTL_REG;
|
|
|
|
case GSBI_ID_5:
|
|
|
|
return GSBI5_CTL_REG;
|
|
|
|
case GSBI_ID_6:
|
|
|
|
return GSBI6_CTL_REG;
|
|
|
|
case GSBI_ID_7:
|
|
|
|
return GSBI7_CTL_REG;
|
|
|
|
default:
|
|
|
|
printk(BIOS_ERR, "Unsupported GSBI%d\n", gsbi_id);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2014-11-22 00:33:26 +01:00
|
|
|
|
|
|
|
gsbi_return_t gsbi_init(gsbi_id_t gsbi_id, gsbi_protocol_t protocol)
|
|
|
|
{
|
2019-10-24 05:45:23 +02:00
|
|
|
unsigned int reg_val;
|
|
|
|
unsigned int m = 1;
|
|
|
|
unsigned int n = 4;
|
|
|
|
unsigned int pre_div = 4;
|
|
|
|
unsigned int src = 3;
|
|
|
|
unsigned int mnctr_mode = 2;
|
2015-02-19 12:13:26 +01:00
|
|
|
void *gsbi_ctl = gsbi_ctl_reg_addr(gsbi_id);
|
2014-11-22 00:33:26 +01:00
|
|
|
|
2015-02-19 12:13:26 +01:00
|
|
|
if (!gsbi_ctl)
|
|
|
|
return GSBI_ID_ERROR;
|
2014-11-22 00:33:26 +01:00
|
|
|
|
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(GSBI_HCLK_CTL(gsbi_id),
|
|
|
|
(1 << GSBI_HCLK_CTL_GATE_ENA) | (1 << GSBI_HCLK_CTL_BRANCH_ENA));
|
2014-11-22 00:33:26 +01:00
|
|
|
|
2015-02-19 12:13:26 +01:00
|
|
|
if (gsbi_init_board(gsbi_id))
|
|
|
|
return GSBI_UNSUPPORTED;
|
2014-11-22 00:33:26 +01:00
|
|
|
|
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(GSBI_QUP_APSS_NS_REG(gsbi_id), 0);
|
|
|
|
write32(GSBI_QUP_APSS_MD_REG(gsbi_id), 0);
|
2015-02-19 12:13:26 +01:00
|
|
|
|
|
|
|
reg_val = ((m & GSBI_QUP_APPS_M_MASK) << GSBI_QUP_APPS_M_SHFT) |
|
|
|
|
((~n & GSBI_QUP_APPS_D_MASK) << GSBI_QUP_APPS_D_SHFT);
|
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(GSBI_QUP_APSS_MD_REG(gsbi_id), reg_val);
|
2015-02-19 12:13:26 +01:00
|
|
|
|
|
|
|
reg_val = (((~(n - m)) & GSBI_QUP_APPS_N_MASK) <<
|
|
|
|
GSBI_QUP_APPS_N_SHFT) |
|
|
|
|
((mnctr_mode & GSBI_QUP_APPS_MNCTR_MODE_MSK) <<
|
|
|
|
GSBI_QUP_APPS_MNCTR_MODE_SFT) |
|
|
|
|
(((pre_div - 1) & GSBI_QUP_APPS_PRE_DIV_MSK) <<
|
|
|
|
GSBI_QUP_APPS_PRE_DIV_SFT) |
|
|
|
|
(src & GSBI_QUP_APPS_SRC_SEL_MSK);
|
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(GSBI_QUP_APSS_NS_REG(gsbi_id), reg_val);
|
2014-11-22 00:33:26 +01:00
|
|
|
|
2015-02-19 12:13:26 +01:00
|
|
|
reg_val |= (1 << GSBI_QUP_APPS_ROOT_ENA_SFT) |
|
|
|
|
(1 << GSBI_QUP_APPS_MNCTR_EN_SFT);
|
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(GSBI_QUP_APSS_NS_REG(gsbi_id), reg_val);
|
2014-11-22 00:33:26 +01:00
|
|
|
|
2015-02-19 12:13:26 +01:00
|
|
|
reg_val |= (1 << GSBI_QUP_APPS_BRANCH_ENA_SFT);
|
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(GSBI_QUP_APSS_NS_REG(gsbi_id), reg_val);
|
2015-02-19 12:13:26 +01:00
|
|
|
|
|
|
|
/*Select i2c protocol*/
|
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(gsbi_ctl,
|
|
|
|
((GSBI_CTL_PROTO_I2C & GSBI_CTL_PROTO_CODE_MSK) << GSBI_CTL_PROTO_CODE_SFT));
|
2014-11-22 00:33:26 +01:00
|
|
|
|
2015-02-19 12:13:26 +01:00
|
|
|
return GSBI_SUCCESS;
|
2014-11-22 00:33:26 +01:00
|
|
|
}
|