From 2fe03a1c82c77fdd54c90bf8be8713f3c06a64f8 Mon Sep 17 00:00:00 2001 From: Lokesh Vutla Date: Mon, 17 Aug 2020 11:00:47 +0530 Subject: [PATCH 1/4] firmware: ti_sci: drop the device ids to resource id translation table With ABI 3.0, sysfw deprecated special resource types used for AM65x SoC. Instead started using device id as resource type similar to the convention used in J721E SOC. Signed-off-by: Lokesh Vutla --- drivers/firmware/ti_sci.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 15f5b0b14cc..a784b4ea29f 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -3175,16 +3175,6 @@ static const struct ti_sci_desc ti_sci_pmmc_k2g_desc = { .rm_type_map = NULL, }; -static struct ti_sci_rm_type_map ti_sci_am654_rm_type_map[] = { - {.dev_id = 56, .type = 0x00b}, /* GIC_IRQ */ - {.dev_id = 179, .type = 0x000}, /* MAIN_NAV_UDMASS_IA0 */ - {.dev_id = 187, .type = 0x009}, /* MAIN_NAV_RA */ - {.dev_id = 188, .type = 0x006}, /* MAIN_NAV_UDMAP */ - {.dev_id = 194, .type = 0x007}, /* MCU_NAV_UDMAP */ - {.dev_id = 195, .type = 0x00a}, /* MCU_NAV_RA */ - {.dev_id = 0, .type = 0x000}, /* end of table */ -}; - /* Description for AM654 */ static const struct ti_sci_desc ti_sci_pmmc_am654_desc = { .default_host_id = 12, @@ -3193,7 +3183,7 @@ static const struct ti_sci_desc ti_sci_pmmc_am654_desc = { /* Limited by MBOX_TX_QUEUE_LEN. K2G can handle upto 128 messages! */ .max_msgs = 20, .max_msg_size = 60, - .rm_type_map = ti_sci_am654_rm_type_map, + .rm_type_map = NULL, }; static const struct udevice_id ti_sci_ids[] = { From 4986b15485997906fe881bb919b537538b7a0ffc Mon Sep 17 00:00:00 2001 From: Lokesh Vutla Date: Mon, 17 Aug 2020 11:00:48 +0530 Subject: [PATCH 2/4] firmware: ti_sci: Drop unused structure ti_sci_rm_type_map struct ti_sci_rm_type_map is no longer used. Drop its definition and its declarations. Signed-off-by: Lokesh Vutla --- drivers/firmware/ti_sci.c | 52 +++------------------------------------ 1 file changed, 3 insertions(+), 49 deletions(-) diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index a784b4ea29f..e311f55ef82 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -60,14 +60,12 @@ struct ti_sci_rm_type_map { * @max_msgs: Maximum number of messages that can be pending * simultaneously in the system * @max_msg_size: Maximum size of data per message that can be handled. - * @rm_type_map: RM resource type mapping structure. */ struct ti_sci_desc { u8 default_host_id; int max_rx_timeout_ms; int max_msgs; int max_msg_size; - struct ti_sci_rm_type_map *rm_type_map; }; /** @@ -1605,33 +1603,6 @@ static int ti_sci_cmd_core_reboot(const struct ti_sci_handle *handle) return ret; } -static int ti_sci_get_resource_type(struct ti_sci_info *info, u16 dev_id, - u16 *type) -{ - struct ti_sci_rm_type_map *rm_type_map = info->desc->rm_type_map; - bool found = false; - int i; - - /* If map is not provided then assume dev_id is used as type */ - if (!rm_type_map) { - *type = dev_id; - return 0; - } - - for (i = 0; rm_type_map[i].dev_id; i++) { - if (rm_type_map[i].dev_id == dev_id) { - *type = rm_type_map[i].type; - found = true; - break; - } - } - - if (!found) - return -EINVAL; - - return 0; -} - /** * ti_sci_get_resource_range - Helper to get a range of resources assigned * to a host. Resource is uniquely identified by @@ -1654,7 +1625,6 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle, struct ti_sci_msg_req_get_resource_range req; struct ti_sci_xfer *xfer; struct ti_sci_info *info; - u16 type; int ret = 0; if (IS_ERR(handle)) @@ -1673,14 +1643,8 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle, return ret; } - ret = ti_sci_get_resource_type(info, dev_id, &type); - if (ret) { - dev_err(dev, "rm type lookup failed for %u\n", dev_id); - goto fail; - } - req.secondary_host = s_host; - req.type = type & MSG_RM_RESOURCE_TYPE_MASK; + req.type = dev_id & MSG_RM_RESOURCE_TYPE_MASK; req.subtype = subtype & MSG_RM_RESOURCE_SUBTYPE_MASK; ret = ti_sci_do_xfer(info, xfer); @@ -3096,7 +3060,6 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle, struct udevice *dev, u32 dev_id, char *of_prop) { u32 resource_subtype; - u16 resource_type; struct ti_sci_resource *res; bool valid_set = false; int sets, i, ret; @@ -3120,13 +3083,6 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle, if (!res->desc) return ERR_PTR(-ENOMEM); - ret = ti_sci_get_resource_type(handle_to_ti_sci_info(handle), dev_id, - &resource_type); - if (ret) { - dev_err(dev, "No valid resource type for %u\n", dev_id); - return ERR_PTR(-EINVAL); - } - ret = dev_read_u32_array(dev, of_prop, temp, res->sets); if (ret) return ERR_PTR(-EINVAL); @@ -3139,7 +3095,7 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle, &res->desc[i].num); if (ret) { dev_dbg(dev, "type %d subtype %d not allocated for host %d\n", - resource_type, resource_subtype, + dev_id, resource_subtype, handle_to_ti_sci_info(handle)->host_id); res->desc[i].start = 0; res->desc[i].num = 0; @@ -3148,7 +3104,7 @@ devm_ti_sci_get_of_resource(const struct ti_sci_handle *handle, valid_set = true; dev_dbg(dev, "res type = %d, subtype = %d, start = %d, num = %d\n", - resource_type, resource_subtype, res->desc[i].start, + dev_id, resource_subtype, res->desc[i].start, res->desc[i].num); res->desc[i].res_map = @@ -3172,7 +3128,6 @@ static const struct ti_sci_desc ti_sci_pmmc_k2g_desc = { /* Limited by MBOX_TX_QUEUE_LEN. K2G can handle upto 128 messages! */ .max_msgs = 20, .max_msg_size = 64, - .rm_type_map = NULL, }; /* Description for AM654 */ @@ -3183,7 +3138,6 @@ static const struct ti_sci_desc ti_sci_pmmc_am654_desc = { /* Limited by MBOX_TX_QUEUE_LEN. K2G can handle upto 128 messages! */ .max_msgs = 20, .max_msg_size = 60, - .rm_type_map = NULL, }; static const struct udevice_id ti_sci_ids[] = { From e66ae8e16b211eba3c61cc087a8c386d444549c7 Mon Sep 17 00:00:00 2001 From: Lokesh Vutla Date: Mon, 17 Aug 2020 11:00:49 +0530 Subject: [PATCH 3/4] arm: dts: k3-am65: Update the RM resource types Update the ringacc and udma dt nodes to use the latest RM resource types similar to the ones used in k3-j721e dt nodes. Signed-off-by: Lokesh Vutla --- arch/arm/dts/k3-am65-mcu.dtsi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm/dts/k3-am65-mcu.dtsi b/arch/arm/dts/k3-am65-mcu.dtsi index 9717cae0a8b..0b07e188b59 100644 --- a/arch/arm/dts/k3-am65-mcu.dtsi +++ b/arch/arm/dts/k3-am65-mcu.dtsi @@ -135,7 +135,7 @@ <0x0 0x2a500000 0x0 0x40000>; reg-names = "rt", "fifos", "proxy_gcfg", "proxy_target"; ti,num-rings = <286>; - ti,sci-rm-range-gp-rings = <0x2>; /* GP ring range */ + ti,sci-rm-range-gp-rings = <0x1>; /* GP ring range */ ti,dma-ring-reset-quirk; ti,sci = <&dmsc>; ti,sci-dev-id = <195>; @@ -153,11 +153,11 @@ ti,sci-dev-id = <194>; ti,ringacc = <&mcu_ringacc>; - ti,sci-rm-range-tchan = <0x1>, /* TX_HCHAN */ - <0x2>; /* TX_CHAN */ - ti,sci-rm-range-rchan = <0x3>, /* RX_HCHAN */ - <0x4>; /* RX_CHAN */ - ti,sci-rm-range-rflow = <0x5>; /* GP RFLOW */ + ti,sci-rm-range-tchan = <0xf>, /* TX_HCHAN */ + <0xd>; /* TX_CHAN */ + ti,sci-rm-range-rchan = <0xb>, /* RX_HCHAN */ + <0xa>; /* RX_CHAN */ + ti,sci-rm-range-rflow = <0x0>; /* GP RFLOW */ }; }; From b892b6d1e0afef8d47f256d5b3ca4687bed1bee3 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 27 Aug 2020 15:43:48 +0200 Subject: [PATCH 4/4] ti: common: Remove additional i2c read for board detection There shouldn't be a need to call additional i2c read if above failed already. Based on comment it should be enough to try to detect legacy boards which are mentioned in the comment. Fixes: 2463f6728e82 ("ti: common: board_detect: Allow DM I2C without CONFIG_DM_I2C_COMPAT") Fixes: 0bea813d0018 ("ARM: omap-common: Add standard access for board description EEPROM") Signed-off-by: Michal Simek --- board/ti/common/board_detect.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c index e09ecda4d7e..8b3b4bc8253 100644 --- a/board/ti/common/board_detect.c +++ b/board/ti/common/board_detect.c @@ -113,18 +113,15 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr, /* Corrupted data??? */ if (hdr_read != header) { - rc = dm_i2c_read(dev, 0, (uint8_t *)&hdr_read, 4); /* * read the eeprom header using i2c again, but use only a * 1 byte address (some legacy boards need this..) */ - if (rc) { - rc = i2c_set_chip_offset_len(dev, 1); - if (rc) - return rc; + rc = i2c_set_chip_offset_len(dev, 1); + if (rc) + return rc; - rc = dm_i2c_read(dev, 0, (uint8_t *)&hdr_read, 4); - } + rc = dm_i2c_read(dev, 0, (uint8_t *)&hdr_read, 4); if (rc) return rc; } @@ -153,16 +150,13 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, int dev_addr, /* Corrupted data??? */ if (hdr_read != header) { - rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read, 4); /* * read the eeprom header using i2c again, but use only a * 1 byte address (some legacy boards need this..) */ byte = 1; - if (rc) { - rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read, - 4); - } + rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read, + 4); if (rc) return rc; }