aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/components/ContentView/ViewSelector.jsx
blob: 43a539956d2bf22b9e4c76e103b0fc639e7d780c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
3 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
/*******************************************************************************

  Intel SmartPHY DSL PCIe Endpoint/ACA Linux driver
  Copyright(c) 2016 Intel Corporation.

  This program is free software; you can redistribute it and/or modify it
  under the terms and conditions of the GNU General Public License,
  version 2, as published by the Free Software Foundation.

  This program is distributed in the hope it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  more details.

  You should have received a copy of the GNU General Public License along with
  this program; if not, write to the Free Software Foundation, Inc.,
  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.

  The full GNU General Public License is included in this distribution in
  the file called "COPYING".

*******************************************************************************/

#include <linux/delay.h>
#include <linux/mutex.h>

#include "regs.h"
#include "ep.h"
#include "misc.h"

#define padc_getbit(p, r)	(!!(rd32(r) & (1 << p)))
#define padc_setbit(p, r)	wr32_mask(0, BIT(p), r)
#define padc_clearbit(p, r)	wr32_mask(BIT(p), 0, r)

void dc_ep_clkod_disable(struct dc_ep_priv *priv)
{
	wr32_mask(0, IF_CLKOD_ALL, IF_CLK);
}

void dc_ep_icu_init(struct dc_ep_priv *priv)
{
	/* Enable all interrupts in ICU level */
	wr32(ICU_DMA_TX_ALL, ICU_DMA_TX_IMER);
	wr32(ICU_DMA_RX_ALL, ICU_DMA_RX_IMER);
	wr32(ICU_TOP_ALL, ICU_IMER);

	if (priv->msi_mode == DC_EP_4_MSI_MODE)
		wr32(PCI_MSI_4_MODE, RCU_MSI);
	else
		wr32(PCI_MSI_8_MODE, RCU_MSI);

	/* PCIe app has to enable all MSI interrupts regardless of MSI mode */
	wr32(PCIE_MSI_EN_ALL, PCIE_APPL_MSI_EN);
}

void dc_ep_icu_disable(struct dc_ep_priv *priv)
{
	/* Disable all PCIe related interrupts */
	wr32(0, PCIE_APPL_MSI_EN);

	wr32(PCI_MSI_8_MODE, RCU_MSI);

	/* Disable all interrupts in ICU level */
	wr32(0, ICU_DMA_TX_IMER);
	wr32(0, ICU_DMA_RX_IMER);
	wr32(0, ICU_IMER);
}

void dc_ep_icu_dis_intr(struct dc_ep_priv *priv, u32 bits)
{
	wr32_mask(~bits, 0, ICU_IMER);
}

void dc_ep_icu_en_intr(struct dc_ep_priv *priv, u32 bits)
{
	wr32_mask(0, bits, ICU_IMER);
}

void dc_ep_assert_device(struct dc_ep_priv *priv, u32 bits)
{
	struct dc_aca *aca = to_aca(priv);

	spin_lock(&aca->rcu_lock);
	wr32_mask(0, bits, RCU_REQ);
	spin_unlock(&aca->rcu_lock);
}

void dc_ep_deassert_device(struct dc_ep_priv *priv, u32 bits)
{
	struct dc_aca *aca = to_aca(priv);

	spin_lock(&aca->rcu_lock);
	wr32_mask(bits, 0, RCU_REQ);
	spin_unlock(&aca->rcu_lock);
}

int dc_ep_reset_device(struct dc_ep_priv *priv, u32 bits)
{
	int retry = EP_TIMEOUT;

	wr32(bits, RCU_REQ);
	do { } while (retry-- && (!(rd32(RCU_STAT) & bits)));

	if (retry == 0) {
		dev_err(priv->dev, "%s failed to reset\n", __func__);
		return -ETIME;
	}
	return 0;
}

int dc_ep_clk_on(struct dc_ep_priv *priv, u32 bits)
{
	int retry = EP_TIMEOUT;
	struct dc_aca *aca = to_aca(priv);

	spin_lock(&aca->clk_lock);
	wr32_mask(bits, 0, PMU_PWDCR);
	spin_unlock(&aca->clk_lock);

	do { } while (--retry && (rd32(PMU_SR) & bits));

	if (!retry) {
		dev_err(priv->dev, "%s failed\n", __func__);
		return -ETIME;
	}
	return 0;
}

int dc_ep_clk_off(struct dc_ep_priv *priv, u32 bits)
{
	int retry = EP_TIMEOUT;
	struct dc_aca *aca = to_aca(priv);

	spin_lock(&aca->clk_lock);
	wr32_mask(0, bits, PMU_PWDCR);
	spin_unlock(&aca->clk_lock);

	do {} while (--retry
		&& (!(rd32(PMU_SR) & bits)));
	if (!retry) {
		dev_err(priv->dev, "%s failed\n", __func__);
		return -ETIME;
	}
	return 0;
}

int dc_ep_clk_set(struct dc_ep_priv *priv, u32 sysclk, u32 ppeclk)
{
	struct dc_aca *aca = to_aca(priv);

	if (sysclk > SYS_CLK_MAX || ppeclk > PPE_CLK_MAX)
		return -EINVAL;

	spin_lock(&aca->clk_lock);
	wr32_mask(PPE_CLK | SYS_CLK,
		SM(sysclk, SYS_CLK) | SM(ppeclk, PPE_CLK), PLL_OMCFG);
	spin_unlock(&aca->clk_lock);
	return 0;
}

int dc_ep_clk_get(struct dc_ep_priv *priv, u32 *sysclk, u32 *ppeclk)
{
	u32 val;

	val = rd32(PLL_OMCFG);
	*sysclk = MS(val, SYS_CLK);
	*ppeclk = MS(val, PPE_CLK);
	return 0;
}

int dc_ep_gpio_dir(struct dc_ep_priv *priv, u32 gpio, int dir)
{
	struct dc_aca *aca = to_aca(priv);

	if (gpio > aca->max_gpio)
		return -EINVAL;

	if ((dir != GPIO_DIR_IN) && (dir != GPIO_DIR_OUT))
		return -EINVAL;

	if (dir == GPIO_DIR_IN)
		wr32(BIT(gpio), GPIO_DIRCLR);
	else
		wr32(BIT(gpio), GPIO_DIRSET);
	return 0;
}

int dc_ep_gpio_set(struct dc_ep_priv *priv, u32 gpio, int val)
{
	struct dc_aca *aca = to_aca(priv);

	if (gpio > aca->max_gpio)
		return -EINVAL;

	dc_ep_gpio_dir(priv, gpio, GPIO_DIR_OUT);

	if (val)
		wr32(BIT(gpio), GPIO_OUTSET);
	else
		wr32(BIT(gpio), GPIO_OUTCLR);
	return 0;
}

int dc_ep_gpio_get(struct dc_ep_priv *priv, u32 gpio, int *val)
{
	u32 dir;
	struct dc_aca *aca = to_aca(priv);

	if (gpio > aca->max_gpio)
		return -EINVAL;

	dir = rd32(GPIO_DIR);
	if ((dir >> gpio) & 0x1)
		*val = (rd32(GPIO_OUT) >> gpio) & 0x1;
	else
		*val = (rd32(GPIO_IN) >> gpio) & 0x1;
	return 0;
}

int dc_ep_pinmux_set(struct dc_ep_priv *priv, u32 gpio, int func)
{
	struct dc_aca *aca = to_aca(priv);

	if (gpio > aca->max_gpio)
		return -EINVAL;

	if (func >= MUX_FUNC_RES)
		return -EINVAL;

	mutex_lock(&aca->pin_lock);
	wr32_mask(PADC_MUX_M, func, PADC_MUX(gpio));