1
0
Files
Greg Kroah-Hartman c89388d301 Merge 4.9.138 into android-4.9
Changes in 4.9.138
	powerpc/eeh: Fix possible null deref in eeh_dump_dev_log()
	tty: check name length in tty_find_polling_driver()
	ARM: imx_v6_v7_defconfig: Select CONFIG_TMPFS_POSIX_ACL
	powerpc/nohash: fix undefined behaviour when testing page size support
	drm/omap: fix memory barrier bug in DMM driver
	media: pci: cx23885: handle adding to list failure
	MIPS: kexec: Mark CPU offline before disabling local IRQ
	powerpc/boot: Ensure _zimage_start is a weak symbol
	MIPS/PCI: Call pcie_bus_configure_settings() to set MPS/MRRS
	sc16is7xx: Fix for multi-channel stall
	media: tvp5150: fix width alignment during set_selection()
	powerpc/selftests: Wait all threads to join
	9p locks: fix glock.client_id leak in do_lock
	9p: clear dangling pointers in p9stat_free
	cdrom: fix improper type cast, which can leat to information leak.
	scsi: qla2xxx: Fix incorrect port speed being set for FC adapters
	scsi: qla2xxx: shutdown chip if reset fail
	fuse: Fix use-after-free in fuse_dev_do_read()
	fuse: Fix use-after-free in fuse_dev_do_write()
	fuse: fix blocked_waitq wakeup
	fuse: set FR_SENT while locked
	mm: do not bug_on on incorrect length in __mm_populate()
	e1000: avoid null pointer dereference on invalid stat type
	e1000: fix race condition between e1000_down() and e1000_watchdog
	bna: ethtool: Avoid reading past end of buffer
	parisc: Align os_hpmc_size on word boundary
	parisc: Fix HPMC handler by increasing size to multiple of 16 bytes
	parisc: Fix exported address of os_hpmc handler
	MIPS: Loongson-3: Fix CPU UART irq delivery problem
	MIPS: Loongson-3: Fix BRIDGE irq delivery problem
	xtensa: add NOTES section to the linker script
	xtensa: make sure bFLT stack is 16 byte aligned
	xtensa: fix boot parameters address translation
	clk: s2mps11: Fix matching when built as module and DT node contains compatible
	clk: at91: Fix division by zero in PLL recalc_rate()
	clk: rockchip: Fix static checker warning in rockchip_ddrclk_get_parent call
	libceph: bump CEPH_MSG_MAX_DATA_LEN
	Revert "ceph: fix dentry leak in splice_dentry()"
	mach64: fix display corruption on big endian machines
	mach64: fix image corruption due to reading accelerator registers
	reset: hisilicon: fix potential NULL pointer dereference
	vhost/scsi: truncate T10 PI iov_iter to prot_bytes
	ocfs2: fix a misuse a of brelse after failing ocfs2_check_dir_entry
	mm: thp: relax __GFP_THISNODE for MADV_HUGEPAGE mappings
	netfilter: conntrack: fix calculation of next bucket number in early_drop
	mtd: docg3: don't set conflicting BCH_CONST_PARAMS option
	of, numa: Validate some distance map rules
	termios, tty/tty_baudrate.c: fix buffer overrun
	arch/alpha, termios: implement BOTHER, IBSHIFT and termios2
	Btrfs: fix cur_offset in the error case for nocow
	Btrfs: fix data corruption due to cloning of eof block
	clockevents/drivers/i8253: Add support for PIT shutdown quirk
	ext4: add missing brelse() update_backups()'s error path
	ext4: add missing brelse() in set_flexbg_block_bitmap()'s error path
	ext4: add missing brelse() add_new_gdb_meta_bg()'s error path
	ext4: avoid potential extra brelse in setup_new_flex_group_blocks()
	ext4: fix possible inode leak in the retry loop of ext4_resize_fs()
	ext4: avoid buffer leak in ext4_orphan_add() after prior errors
	ext4: fix missing cleanup if ext4_alloc_flex_bg_array() fails while resizing
	ext4: avoid possible double brelse() in add_new_gdb() on error path
	ext4: fix possible leak of sbi->s_group_desc_leak in error path
	ext4: fix possible leak of s_journal_flag_rwsem in error path
	ext4: release bs.bh before re-using in ext4_xattr_block_find()
	ext4: fix buffer leak in ext4_xattr_move_to_block() on error path
	ext4: fix buffer leak in __ext4_read_dirblock() on error path
	mount: Retest MNT_LOCKED in do_umount
	mount: Don't allow copying MNT_UNBINDABLE|MNT_LOCKED mounts
	mount: Prevent MNT_DETACH from disconnecting locked mounts
	sunrpc: correct the computation for page_ptr when truncating
	nfsd: COPY and CLONE operations require the saved filehandle to be set
	rtc: hctosys: Add missing range error reporting
	fuse: fix use-after-free in fuse_direct_IO()
	fuse: fix leaked notify reply
	configfs: replace strncpy with memcpy
	lib/ubsan.c: don't mark __ubsan_handle_builtin_unreachable as noreturn
	hugetlbfs: fix kernel BUG at fs/hugetlbfs/inode.c:444!
	mm: migration: fix migration of huge PMD shared pages
	drm/rockchip: Allow driver to be shutdown on reboot/kexec
	drm/dp_mst: Check if primary mstb is null
	drm/i915/hdmi: Add HDMI 2.0 audio clock recovery N values
	drm/i915/execlists: Force write serialisation into context image vs execution
	KVM: arm64: Fix caching of host MDCR_EL2 value
	Linux 4.9.138

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2019-02-11 22:54:32 +03:00

148 lines
3.7 KiB
C

/*
* Copyright (c) 2016 Rockchip Electronics Co. Ltd.
* Author: Lin Huang <hl@rock-chips.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that 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 <linux/arm-smccc.h>
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/io.h>
#include <linux/slab.h>
#include <soc/rockchip/rockchip_sip.h>
#include "clk.h"
struct rockchip_ddrclk {
struct clk_hw hw;
void __iomem *reg_base;
int mux_offset;
int mux_shift;
int mux_width;
int div_shift;
int div_width;
int ddr_flag;
spinlock_t *lock;
};
#define to_rockchip_ddrclk_hw(hw) container_of(hw, struct rockchip_ddrclk, hw)
static int rockchip_ddrclk_sip_set_rate(struct clk_hw *hw, unsigned long drate,
unsigned long prate)
{
struct rockchip_ddrclk *ddrclk = to_rockchip_ddrclk_hw(hw);
unsigned long flags;
struct arm_smccc_res res;
spin_lock_irqsave(ddrclk->lock, flags);
arm_smccc_smc(ROCKCHIP_SIP_DRAM_FREQ, drate, 0,
ROCKCHIP_SIP_CONFIG_DRAM_SET_RATE,
0, 0, 0, 0, &res);
spin_unlock_irqrestore(ddrclk->lock, flags);
return res.a0;
}
static unsigned long
rockchip_ddrclk_sip_recalc_rate(struct clk_hw *hw,
unsigned long parent_rate)
{
struct arm_smccc_res res;
arm_smccc_smc(ROCKCHIP_SIP_DRAM_FREQ, 0, 0,
ROCKCHIP_SIP_CONFIG_DRAM_GET_RATE,
0, 0, 0, 0, &res);
return res.a0;
}
static long rockchip_ddrclk_sip_round_rate(struct clk_hw *hw,
unsigned long rate,
unsigned long *prate)
{
struct arm_smccc_res res;
arm_smccc_smc(ROCKCHIP_SIP_DRAM_FREQ, rate, 0,
ROCKCHIP_SIP_CONFIG_DRAM_ROUND_RATE,
0, 0, 0, 0, &res);
return res.a0;
}
static u8 rockchip_ddrclk_get_parent(struct clk_hw *hw)
{
struct rockchip_ddrclk *ddrclk = to_rockchip_ddrclk_hw(hw);
u32 val;
val = clk_readl(ddrclk->reg_base +
ddrclk->mux_offset) >> ddrclk->mux_shift;
val &= GENMASK(ddrclk->mux_width - 1, 0);
return val;
}
static const struct clk_ops rockchip_ddrclk_sip_ops = {
.recalc_rate = rockchip_ddrclk_sip_recalc_rate,
.set_rate = rockchip_ddrclk_sip_set_rate,
.round_rate = rockchip_ddrclk_sip_round_rate,
.get_parent = rockchip_ddrclk_get_parent,
};
struct clk *rockchip_clk_register_ddrclk(const char *name, int flags,
const char *const *parent_names,
u8 num_parents, int mux_offset,
int mux_shift, int mux_width,
int div_shift, int div_width,
int ddr_flag, void __iomem *reg_base,
spinlock_t *lock)
{
struct rockchip_ddrclk *ddrclk;
struct clk_init_data init;
struct clk *clk;
ddrclk = kzalloc(sizeof(*ddrclk), GFP_KERNEL);
if (!ddrclk)
return ERR_PTR(-ENOMEM);
init.name = name;
init.parent_names = parent_names;
init.num_parents = num_parents;
init.flags = flags;
init.flags |= CLK_SET_RATE_NO_REPARENT;
switch (ddr_flag) {
case ROCKCHIP_DDRCLK_SIP:
init.ops = &rockchip_ddrclk_sip_ops;
break;
default:
pr_err("%s: unsupported ddrclk type %d\n", __func__, ddr_flag);
kfree(ddrclk);
return ERR_PTR(-EINVAL);
}
ddrclk->reg_base = reg_base;
ddrclk->lock = lock;
ddrclk->hw.init = &init;
ddrclk->mux_offset = mux_offset;
ddrclk->mux_shift = mux_shift;
ddrclk->mux_width = mux_width;
ddrclk->div_shift = div_shift;
ddrclk->div_width = div_width;
ddrclk->ddr_flag = ddr_flag;
clk = clk_register(NULL, &ddrclk->hw);
if (IS_ERR(clk))
kfree(ddrclk);
return clk;
}