blob: 858b15ec49a86122c38a7d732e2a772c653d9a58 [file] [log] [blame]
Gagan Mac4cc403f2013-05-01 12:13:31 -06001/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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 */
Stephen Boyd8704c7f2012-02-05 01:07:45 -080012
13#define pr_fmt(fmt) "AXI: %s(): " fmt, __func__
14
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070015#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/module.h>
18#include <linux/slab.h>
19#include <linux/mutex.h>
20#include <linux/radix-tree.h>
21#include <linux/clk.h>
22#include <mach/msm_bus_board.h>
23#include <mach/msm_bus.h>
24#include "msm_bus_core.h"
25
26static DEFINE_MUTEX(msm_bus_config_lock);
27
28/**
29 * msm_bus_axi_porthalt() - Halt the given axi master port
30 * @master_port: AXI Master port to be halted
31 */
32int msm_bus_axi_porthalt(int master_port)
33{
34 int ret = 0;
35 int priv_id;
36 struct msm_bus_fabric_device *fabdev;
37
38 priv_id = msm_bus_board_get_iid(master_port);
39 MSM_BUS_DBG("master_port: %d iid: %d fabid%d\n",
40 master_port, priv_id, GET_FABID(priv_id));
41 fabdev = msm_bus_get_fabric_device(GET_FABID(priv_id));
Gagan Mac4cc403f2013-05-01 12:13:31 -060042 if (IS_ERR_OR_NULL(fabdev)) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070043 MSM_BUS_ERR("Fabric device not found for mport: %d\n",
44 master_port);
45 return -ENODEV;
46 }
47 mutex_lock(&msm_bus_config_lock);
48 ret = fabdev->algo->port_halt(fabdev, priv_id);
49 mutex_unlock(&msm_bus_config_lock);
50 return ret;
51}
52EXPORT_SYMBOL(msm_bus_axi_porthalt);
53
54/**
55 * msm_bus_axi_portunhalt() - Unhalt the given axi master port
56 * @master_port: AXI Master port to be unhalted
57 */
58int msm_bus_axi_portunhalt(int master_port)
59{
60 int ret = 0;
61 int priv_id;
62 struct msm_bus_fabric_device *fabdev;
63
64 priv_id = msm_bus_board_get_iid(master_port);
65 MSM_BUS_DBG("master_port: %d iid: %d fabid: %d\n",
66 master_port, priv_id, GET_FABID(priv_id));
67 fabdev = msm_bus_get_fabric_device(GET_FABID(priv_id));
Gagan Mac4cc403f2013-05-01 12:13:31 -060068 if (IS_ERR_OR_NULL(fabdev)) {
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070069 MSM_BUS_ERR("Fabric device not found for mport: %d\n",
70 master_port);
71 return -ENODEV;
72 }
73 mutex_lock(&msm_bus_config_lock);
74 ret = fabdev->algo->port_unhalt(fabdev, priv_id);
75 mutex_unlock(&msm_bus_config_lock);
76 return ret;
77}
78EXPORT_SYMBOL(msm_bus_axi_portunhalt);