Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/powerpc/platforms/83xx/usb_837x.c
26481 views
1
// SPDX-License-Identifier: GPL-2.0-or-later
2
/*
3
* Freescale 83xx USB SOC setup code
4
*
5
* Copyright (C) 2007 Freescale Semiconductor, Inc.
6
* Author: Li Yang
7
*/
8
9
#include <linux/stddef.h>
10
#include <linux/kernel.h>
11
#include <linux/errno.h>
12
#include <linux/of.h>
13
#include <linux/of_address.h>
14
#include <linux/io.h>
15
16
#include <sysdev/fsl_soc.h>
17
18
#include "mpc83xx.h"
19
20
int __init mpc837x_usb_cfg(void)
21
{
22
void __iomem *immap;
23
struct device_node *np = NULL;
24
const void *prop;
25
int ret = 0;
26
27
np = of_find_compatible_node(NULL, NULL, "fsl-usb2-dr");
28
if (!np || !of_device_is_available(np)) {
29
of_node_put(np);
30
return -ENODEV;
31
}
32
prop = of_get_property(np, "phy_type", NULL);
33
34
if (!prop || (strcmp(prop, "ulpi") && strcmp(prop, "serial"))) {
35
pr_warn("837x USB PHY type not supported\n");
36
of_node_put(np);
37
return -EINVAL;
38
}
39
40
/* Map IMMR space for pin and clock settings */
41
immap = ioremap(get_immrbase(), 0x1000);
42
if (!immap) {
43
of_node_put(np);
44
return -ENOMEM;
45
}
46
47
/* Configure clock */
48
clrsetbits_be32(immap + MPC83XX_SCCR_OFFS, MPC837X_SCCR_USB_DRCM_11,
49
MPC837X_SCCR_USB_DRCM_11);
50
51
/* Configure pin mux for ULPI/serial */
52
clrsetbits_be32(immap + MPC83XX_SICRL_OFFS, MPC837X_SICRL_USB_MASK,
53
MPC837X_SICRL_USB_ULPI);
54
55
iounmap(immap);
56
of_node_put(np);
57
return ret;
58
}
59
60