Path: blob/master/arch/powerpc/platforms/85xx/p1022_rdk.c
26481 views
/*1* P1022 RDK board specific routines2*3* Copyright 2012 Freescale Semiconductor, Inc.4*5* Author: Timur Tabi <[email protected]>6*7* Based on p1022_ds.c8*9* This file is licensed under the terms of the GNU General Public License10* version 2. This program is licensed "as is" without any warranty of any11* kind, whether express or implied.12*/1314#include <linux/fsl/guts.h>15#include <linux/pci.h>16#include <linux/of.h>17#include <linux/of_address.h>18#include <asm/div64.h>19#include <asm/mpic.h>20#include <asm/swiotlb.h>2122#include <sysdev/fsl_soc.h>23#include <sysdev/fsl_pci.h>24#include <asm/udbg.h>25#include "smp.h"2627#include "mpc85xx.h"2829#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)3031/* DIU Pixel Clock bits of the CLKDVDR Global Utilities register */32#define CLKDVDR_PXCKEN 0x8000000033#define CLKDVDR_PXCKINV 0x1000000034#define CLKDVDR_PXCKDLY 0x0600000035#define CLKDVDR_PXCLK_MASK 0x00FF00003637/**38* p1022rdk_set_pixel_clock: program the DIU's clock39*40* @pixclock: the wavelength, in picoseconds, of the clock41*/42static void p1022rdk_set_pixel_clock(unsigned int pixclock)43{44struct device_node *guts_np = NULL;45struct ccsr_guts __iomem *guts;46unsigned long freq;47u64 temp;48u32 pxclk;4950/* Map the global utilities registers. */51guts_np = of_find_compatible_node(NULL, NULL, "fsl,p1022-guts");52if (!guts_np) {53pr_err("p1022rdk: missing global utilities device node\n");54return;55}5657guts = of_iomap(guts_np, 0);58of_node_put(guts_np);59if (!guts) {60pr_err("p1022rdk: could not map global utilities device\n");61return;62}6364/* Convert pixclock from a wavelength to a frequency */65temp = 1000000000000ULL;66do_div(temp, pixclock);67freq = temp;6869/*70* 'pxclk' is the ratio of the platform clock to the pixel clock.71* This number is programmed into the CLKDVDR register, and the valid72* range of values is 2-255.73*/74pxclk = DIV_ROUND_CLOSEST(fsl_get_sys_freq(), freq);75pxclk = clamp_t(u32, pxclk, 2, 255);7677/* Disable the pixel clock, and set it to non-inverted and no delay */78clrbits32(&guts->clkdvdr,79CLKDVDR_PXCKEN | CLKDVDR_PXCKDLY | CLKDVDR_PXCLK_MASK);8081/* Enable the clock and set the pxclk */82setbits32(&guts->clkdvdr, CLKDVDR_PXCKEN | (pxclk << 16));8384iounmap(guts);85}8687/**88* p1022rdk_valid_monitor_port: set the monitor port for sysfs89*/90static enum fsl_diu_monitor_port91p1022rdk_valid_monitor_port(enum fsl_diu_monitor_port port)92{93return FSL_DIU_PORT_DVI;94}9596#endif9798static void __init p1022_rdk_pic_init(void)99{100struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |101MPIC_SINGLE_DEST_CPU,1020, 256, " OpenPIC ");103BUG_ON(mpic == NULL);104mpic_init(mpic);105}106107/*108* Setup the architecture109*/110static void __init p1022_rdk_setup_arch(void)111{112if (ppc_md.progress)113ppc_md.progress("p1022_rdk_setup_arch()", 0);114115#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)116diu_ops.set_pixel_clock = p1022rdk_set_pixel_clock;117diu_ops.valid_monitor_port = p1022rdk_valid_monitor_port;118#endif119120mpc85xx_smp_init();121122fsl_pci_assign_primary();123124swiotlb_detect_4g();125126pr_info("Freescale / iVeia P1022 RDK reference board\n");127}128129machine_arch_initcall(p1022_rdk, mpc85xx_common_publish_devices);130131define_machine(p1022_rdk) {132.name = "P1022 RDK",133.compatible = "fsl,p1022rdk",134.setup_arch = p1022_rdk_setup_arch,135.init_IRQ = p1022_rdk_pic_init,136#ifdef CONFIG_PCI137.pcibios_fixup_bus = fsl_pcibios_fixup_bus,138.pcibios_fixup_phb = fsl_pcibios_fixup_phb,139#endif140.get_irq = mpic_get_irq,141.progress = udbg_progress,142};143144145