blob: 25a749ac228d65e33ae3a1a878ecab5f12b1567c [file] [log] [blame]
Gagan Macf5b34d82013-01-28 17:11:10 -07001/* 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 Mac80a88732013-03-26 13:32:57 -060022#include <mach/socinfo.h>
Gagan Macf5b34d82013-01-28 17:11:10 -070023#include "msm_bus_core.h"
24#include "msm_bus_noc.h"
25#include "msm_bus_bimc.h"
26
27static uint32_t master_iids[MSM_BUS_MASTER_LAST];
28static uint32_t slave_iids[MSM_BUS_SLAVE_LAST - SLAVE_ID_KEY];
29
30static 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 Mac68947fc2013-07-24 17:44:45 -060038 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 Macf5b34d82013-01-28 17:11:10 -070044 master_iids[fabreg->info[i].id] =
45 fabreg->info[i].priv_id;
46 } else {
Gagan Mac68947fc2013-07-24 17:44:45 -060047 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 Macf5b34d82013-01-28 17:11:10 -070054 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
63static 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
76static struct msm_bus_board_algorithm msm_bus_id_algo = {
Gagan Macf5b34d82013-01-28 17:11:10 -070077 .get_iid = msm_bus_get_iid,
78 .assign_iids = msm_bus_assign_iids,
79};
80
81int msm_bus_board_rpm_get_il_ids(uint16_t *id)
82{
83 return -ENXIO;
84}
85
86void msm_bus_board_init(struct msm_bus_fabric_registration *pdata)
87{
Gagan Mac80a88732013-03-26 13:32:57 -060088 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 Macf5b34d82013-01-28 17:11:10 -070093 pdata->board_algo = &msm_bus_id_algo;
94}