1 /* SPDX-License-Identifier: BSD-3-Clause */
3 #include <device/mmio.h>
6 #include <console/console.h>
8 static inline void *gsbi_ctl_reg_addr(gsbi_id_t gsbi_id
)
26 printk(BIOS_ERR
, "Unsupported GSBI%d\n", gsbi_id
);
31 gsbi_return_t
gsbi_init(gsbi_id_t gsbi_id
, gsbi_protocol_t protocol
)
36 unsigned int pre_div
= 4;
38 unsigned int mnctr_mode
= 2;
39 void *gsbi_ctl
= gsbi_ctl_reg_addr(gsbi_id
);
44 write32(GSBI_HCLK_CTL(gsbi_id
),
45 (1 << GSBI_HCLK_CTL_GATE_ENA
) | (1 << GSBI_HCLK_CTL_BRANCH_ENA
));
47 if (gsbi_init_board(gsbi_id
))
48 return GSBI_UNSUPPORTED
;
50 write32(GSBI_QUP_APSS_NS_REG(gsbi_id
), 0);
51 write32(GSBI_QUP_APSS_MD_REG(gsbi_id
), 0);
53 reg_val
= ((m
& GSBI_QUP_APPS_M_MASK
) << GSBI_QUP_APPS_M_SHFT
) |
54 ((~n
& GSBI_QUP_APPS_D_MASK
) << GSBI_QUP_APPS_D_SHFT
);
55 write32(GSBI_QUP_APSS_MD_REG(gsbi_id
), reg_val
);
57 reg_val
= (((~(n
- m
)) & GSBI_QUP_APPS_N_MASK
) <<
58 GSBI_QUP_APPS_N_SHFT
) |
59 ((mnctr_mode
& GSBI_QUP_APPS_MNCTR_MODE_MSK
) <<
60 GSBI_QUP_APPS_MNCTR_MODE_SFT
) |
61 (((pre_div
- 1) & GSBI_QUP_APPS_PRE_DIV_MSK
) <<
62 GSBI_QUP_APPS_PRE_DIV_SFT
) |
63 (src
& GSBI_QUP_APPS_SRC_SEL_MSK
);
64 write32(GSBI_QUP_APSS_NS_REG(gsbi_id
), reg_val
);
66 reg_val
|= (1 << GSBI_QUP_APPS_ROOT_ENA_SFT
) |
67 (1 << GSBI_QUP_APPS_MNCTR_EN_SFT
);
68 write32(GSBI_QUP_APSS_NS_REG(gsbi_id
), reg_val
);
70 reg_val
|= (1 << GSBI_QUP_APPS_BRANCH_ENA_SFT
);
71 write32(GSBI_QUP_APSS_NS_REG(gsbi_id
), reg_val
);
73 /*Select i2c protocol*/
75 ((GSBI_CTL_PROTO_I2C
& GSBI_CTL_PROTO_CODE_MSK
) << GSBI_CTL_PROTO_CODE_SFT
));