Changes in 4.9.335 wifi: mac80211_hwsim: fix debugfs attribute ps with rc table support audit: fix undefined behavior in bit shift for AUDIT_BIT wifi: mac80211: Fix ack frame idr leak when mesh has no route MIPS: pic32: treat port as signed integer af_key: Fix send_acquire race with pfkey_register bus: sunxi-rsb: Support atomic transfers ARM: dts: at91: sam9g20ek: enable udc vbus gpio pinctrl nfc/nci: fix race with opening and closing net: pch_gbe: fix potential memleak in pch_gbe_tx_queue() 9p/fd: fix issue of list_del corruption in p9_fd_cancel() ARM: mxs: fix memory leak in mxs_machine_init() net/mlx4: Check retval of mlx4_bitmap_init net/qla3xxx: fix potential memleak in ql3xxx_send() xfrm: Fix ignored return value in xfrm6_init() NFC: nci: fix memory leak in nci_rx_data_packet() nfc: st-nci: fix incorrect validating logic in EVT_TRANSACTION nfc: st-nci: fix memory leaks in EVT_TRANSACTION net: thunderx: Fix the ACPI memory leak s390/crashdump: fix TOD programmable field size iio: light: apds9960: fix wrong register for gesture gain iio: core: Fix entry not deleted when iio_register_sw_trigger_type() fails kconfig: display recursive dependency resolution hint just once nios2: add FORCE for vmlinuz.gz nilfs2: fix nilfs_sufile_mark_dirty() not set segment usage as dirty serial: 8250: 8250_omap: Avoid RS485 RTS glitch on ->set_termios() xen/platform-pci: add missing free_irq() in error path platform/x86: asus-wmi: add missing pci_dev_put() in asus_wmi_set_xusb2pr() tcp: configurable source port perturb table size net: usb: qmi_wwan: add Telit 0x103a composition drm/amdgpu: always register an MMU notifier for userptr iio: health: afe4403: Fix oob read in afe4403_read_raw iio: health: afe4404: Fix oob read in afe4404_[read|write]_raw hwmon: (i5500_temp) fix missing pci_disable_device() hwmon: (ibmpex) Fix possible UAF when ibmpex_register_bmc() fails net/mlx5: Fix uninitialized variable bug in outlen_write() can: sja1000_isa: sja1000_isa_probe(): add missing free_sja1000dev() can: cc770: cc770_isa_probe(): add missing free_cc770dev() qlcnic: fix sleep-in-atomic-context bugs caused by msleep net: phy: fix null-ptr-deref while probe() failed net: net_netdev: Fix error handling in ntb_netdev_init_module() net/9p: Fix a potential socket leak in p9_socket_open net: hsr: Fix potential use-after-free packet: do not set TP_STATUS_CSUM_VALID on CHECKSUM_COMPLETE net: ethernet: renesas: ravb: Fix promiscuous mode after system resumed hwmon: (coretemp) Check for null before removing sysfs attrs hwmon: (coretemp) fix pci device refcount leak in nv1a_ram_new() btrfs: qgroup: fix sleep from invalid context bug in btrfs_qgroup_inherit() tools/vm/slabinfo-gnuplot: use "grep -E" instead of "egrep" nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry() arm64: Fix panic() when Spectre-v2 causes Spectre-BHB to re-allocate KVM vectors arm64: errata: Fix KVM Spectre-v2 mitigation selection for Cortex-A57/A72 ASoC: ops: Fix bounds check for _sx controls pinctrl: single: Fix potential division by zero iommu/vt-d: Fix PCI device refcount leak in dmar_dev_scope_init() tcp/udp: Fix memory leak in ipv6_renew_options(). Revert "fbdev: fb_pm2fb: Avoid potential divide by zero error" x86/tsx: Add a feature bit for TSX control MSR support x86/pm: Add enumeration check before spec MSRs save/restore setup Bluetooth: L2CAP: Fix accepting connection request for invalid SPSM x86/ioremap: Fix page aligned size calculation in __ioremap_caller() proc: avoid integer type confusion in get_proc_long proc: proc_skip_spaces() shouldn't think it is working on C strings v4l2: don't fall back to follow_pfn() if pin_user_pages_fast() fails Linux 4.9.335 Change-Id: I5a99e366191f445d4de1039f5e82812b37787842 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
171 lines
3.5 KiB
C
171 lines
3.5 KiB
C
/*
|
|
* Joshua Henderson <joshua.henderson@microchip.com>
|
|
* Copyright (C) 2015 Microchip Technology Inc. All rights reserved.
|
|
*
|
|
* This program is free software; you can distribute it and/or modify it
|
|
* under the terms 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.
|
|
*/
|
|
#include <asm/mach-pic32/pic32.h>
|
|
#include <asm/fw/fw.h>
|
|
|
|
#include "pic32mzda.h"
|
|
#include "early_pin.h"
|
|
|
|
/* Default early console parameters */
|
|
#define EARLY_CONSOLE_PORT 1
|
|
#define EARLY_CONSOLE_BAUDRATE 115200
|
|
|
|
#define UART_ENABLE BIT(15)
|
|
#define UART_ENABLE_RX BIT(12)
|
|
#define UART_ENABLE_TX BIT(10)
|
|
#define UART_TX_FULL BIT(9)
|
|
|
|
/* UART1(x == 0) - UART6(x == 5) */
|
|
#define UART_BASE(x) ((x) * 0x0200)
|
|
#define U_MODE(x) UART_BASE(x)
|
|
#define U_STA(x) (UART_BASE(x) + 0x10)
|
|
#define U_TXR(x) (UART_BASE(x) + 0x20)
|
|
#define U_BRG(x) (UART_BASE(x) + 0x40)
|
|
|
|
static void __iomem *uart_base;
|
|
static int console_port = -1;
|
|
|
|
static int __init configure_uart_pins(int port)
|
|
{
|
|
switch (port) {
|
|
case 1:
|
|
pic32_pps_input(IN_FUNC_U2RX, IN_RPB0);
|
|
pic32_pps_output(OUT_FUNC_U2TX, OUT_RPG9);
|
|
break;
|
|
case 5:
|
|
pic32_pps_input(IN_FUNC_U6RX, IN_RPD0);
|
|
pic32_pps_output(OUT_FUNC_U6TX, OUT_RPB8);
|
|
break;
|
|
default:
|
|
return -1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void __init configure_uart(int port, int baud)
|
|
{
|
|
u32 pbclk;
|
|
|
|
pbclk = pic32_get_pbclk(2);
|
|
|
|
__raw_writel(0, uart_base + U_MODE(port));
|
|
__raw_writel(((pbclk / baud) / 16) - 1, uart_base + U_BRG(port));
|
|
__raw_writel(UART_ENABLE, uart_base + U_MODE(port));
|
|
__raw_writel(UART_ENABLE_TX | UART_ENABLE_RX,
|
|
uart_base + PIC32_SET(U_STA(port)));
|
|
}
|
|
|
|
static void __init setup_early_console(int port, int baud)
|
|
{
|
|
if (configure_uart_pins(port))
|
|
return;
|
|
|
|
console_port = port;
|
|
configure_uart(console_port, baud);
|
|
}
|
|
|
|
static char * __init pic32_getcmdline(void)
|
|
{
|
|
/*
|
|
* arch_mem_init() has not been called yet, so we don't have a real
|
|
* command line setup if using CONFIG_CMDLINE_BOOL.
|
|
*/
|
|
#ifdef CONFIG_CMDLINE_OVERRIDE
|
|
return CONFIG_CMDLINE;
|
|
#else
|
|
return fw_getcmdline();
|
|
#endif
|
|
}
|
|
|
|
static int __init get_port_from_cmdline(char *arch_cmdline)
|
|
{
|
|
char *s;
|
|
int port = -1;
|
|
|
|
if (!arch_cmdline || *arch_cmdline == '\0')
|
|
goto _out;
|
|
|
|
s = strstr(arch_cmdline, "earlyprintk=");
|
|
if (s) {
|
|
s = strstr(s, "ttyS");
|
|
if (s)
|
|
s += 4;
|
|
else
|
|
goto _out;
|
|
|
|
port = (*s) - '0';
|
|
}
|
|
|
|
_out:
|
|
return port;
|
|
}
|
|
|
|
static int __init get_baud_from_cmdline(char *arch_cmdline)
|
|
{
|
|
char *s;
|
|
int baud = -1;
|
|
|
|
if (!arch_cmdline || *arch_cmdline == '\0')
|
|
goto _out;
|
|
|
|
s = strstr(arch_cmdline, "earlyprintk=");
|
|
if (s) {
|
|
s = strstr(s, "ttyS");
|
|
if (s)
|
|
s += 6;
|
|
else
|
|
goto _out;
|
|
|
|
baud = 0;
|
|
while (*s >= '0' && *s <= '9')
|
|
baud = baud * 10 + *s++ - '0';
|
|
}
|
|
|
|
_out:
|
|
return baud;
|
|
}
|
|
|
|
void __init fw_init_early_console(void)
|
|
{
|
|
char *arch_cmdline = pic32_getcmdline();
|
|
int baud, port;
|
|
|
|
uart_base = ioremap_nocache(PIC32_BASE_UART, 0xc00);
|
|
|
|
baud = get_baud_from_cmdline(arch_cmdline);
|
|
port = get_port_from_cmdline(arch_cmdline);
|
|
|
|
if (port == -1)
|
|
port = EARLY_CONSOLE_PORT;
|
|
|
|
if (baud == -1)
|
|
baud = EARLY_CONSOLE_BAUDRATE;
|
|
|
|
setup_early_console(port, baud);
|
|
}
|
|
|
|
int prom_putchar(char c)
|
|
{
|
|
if (console_port >= 0) {
|
|
while (__raw_readl(
|
|
uart_base + U_STA(console_port)) & UART_TX_FULL)
|
|
;
|
|
|
|
__raw_writel(c, uart_base + U_TXR(console_port));
|
|
}
|
|
|
|
return 1;
|
|
}
|