Gagan Mac | f5b34d8 | 2013-01-28 17:11:10 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2013, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/device.h> |
| 17 | #include <linux/module.h> |
| 18 | #include <mach/msm_bus.h> |
| 19 | #include <mach/msm_bus_board.h> |
| 20 | #include <mach/board.h> |
| 21 | #include <mach/rpm.h> |
Gagan Mac | 80a8873 | 2013-03-26 13:32:57 -0600 | [diff] [blame] | 22 | #include <mach/socinfo.h> |
Gagan Mac | f5b34d8 | 2013-01-28 17:11:10 -0700 | [diff] [blame] | 23 | #include "msm_bus_core.h" |
| 24 | #include "msm_bus_noc.h" |
| 25 | #include "msm_bus_bimc.h" |
| 26 | |
| 27 | static uint32_t master_iids[MSM_BUS_MASTER_LAST]; |
| 28 | static uint32_t slave_iids[MSM_BUS_SLAVE_LAST - SLAVE_ID_KEY]; |
| 29 | |
| 30 | static void msm_bus_assign_iids(struct msm_bus_fabric_registration |
| 31 | *fabreg, int fabid) |
| 32 | { |
| 33 | int i; |
| 34 | for (i = 0; i < fabreg->len; i++) { |
| 35 | if (!fabreg->info[i].gateway) { |
| 36 | fabreg->info[i].priv_id = fabid + fabreg->info[i].id; |
| 37 | if (fabreg->info[i].id < SLAVE_ID_KEY) { |
Gagan Mac | 68947fc | 2013-07-24 17:44:45 -0600 | [diff] [blame] | 38 | if (fabreg->info[i].id >= MSM_BUS_MASTER_LAST) { |
| 39 | WARN(1, "id %d exceeds array size!\n", |
| 40 | fabreg->info[i].id); |
| 41 | continue; |
| 42 | } |
| 43 | |
Gagan Mac | f5b34d8 | 2013-01-28 17:11:10 -0700 | [diff] [blame] | 44 | master_iids[fabreg->info[i].id] = |
| 45 | fabreg->info[i].priv_id; |
| 46 | } else { |
Gagan Mac | 68947fc | 2013-07-24 17:44:45 -0600 | [diff] [blame] | 47 | if ((fabreg->info[i].id - SLAVE_ID_KEY) >= |
| 48 | (MSM_BUS_SLAVE_LAST - SLAVE_ID_KEY)) { |
| 49 | WARN(1, "id %d exceeds array size!\n", |
| 50 | fabreg->info[i].id); |
| 51 | continue; |
| 52 | } |
| 53 | |
Gagan Mac | f5b34d8 | 2013-01-28 17:11:10 -0700 | [diff] [blame] | 54 | slave_iids[fabreg->info[i].id - (SLAVE_ID_KEY)] |
| 55 | = fabreg->info[i].priv_id; |
| 56 | } |
| 57 | } else { |
| 58 | fabreg->info[i].priv_id = fabreg->info[i].id; |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | static int msm_bus_get_iid(int id) |
| 64 | { |
| 65 | if ((id < SLAVE_ID_KEY && id >= MSM_BUS_MASTER_LAST) || |
| 66 | id >= MSM_BUS_SLAVE_LAST) { |
| 67 | MSM_BUS_ERR("Cannot get iid. Invalid id %d passed\n", id); |
| 68 | return -EINVAL; |
| 69 | } |
| 70 | |
| 71 | return CHECK_ID(((id < SLAVE_ID_KEY) ? master_iids[id] : |
| 72 | slave_iids[id - SLAVE_ID_KEY]), id); |
| 73 | } |
| 74 | |
| 75 | |
| 76 | static struct msm_bus_board_algorithm msm_bus_id_algo = { |
Gagan Mac | f5b34d8 | 2013-01-28 17:11:10 -0700 | [diff] [blame] | 77 | .get_iid = msm_bus_get_iid, |
| 78 | .assign_iids = msm_bus_assign_iids, |
| 79 | }; |
| 80 | |
| 81 | int msm_bus_board_rpm_get_il_ids(uint16_t *id) |
| 82 | { |
| 83 | return -ENXIO; |
| 84 | } |
| 85 | |
| 86 | void msm_bus_board_init(struct msm_bus_fabric_registration *pdata) |
| 87 | { |
Gagan Mac | 80a8873 | 2013-03-26 13:32:57 -0600 | [diff] [blame] | 88 | if (machine_is_msm8226()) |
| 89 | msm_bus_id_algo.board_nfab = NFAB_MSM8226; |
| 90 | else if (machine_is_msm8610()) |
| 91 | msm_bus_id_algo.board_nfab = NFAB_MSM8610; |
| 92 | |
Gagan Mac | f5b34d8 | 2013-01-28 17:11:10 -0700 | [diff] [blame] | 93 | pdata->board_algo = &msm_bus_id_algo; |
| 94 | } |