int clk_disable_usb(struct clk *clk) { char * clk_name; usb_peri_reg_t * peri_a,* peri_b,*peri; //usb_dbg_uart_data_t uart; if(!clk) return -1; clk_name = (char*)clk->priv; peri_a = (usb_peri_reg_t *)P_USB_ADDR0; peri_b = (usb_peri_reg_t *)P_USB_ADDR8; if(!strcmp(clk_name,"usb0")) peri = peri_a; else if(!strcmp(clk_name,"usb1")) peri = peri_b; else{ printk(KERN_ERR "bad usb clk name: %s\n",clk_name); return -1; } #if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6 switch_mod_gate_by_name(clk_name, 0); #endif if(init_count){ init_count--; //uart.d32 = peri->dbg_uart; //uart.b.set_iddq = 1; //peri->dbg_uart = uart.d32; } dmb(); return 0; }
int video_dac_disable() { SET_CBUS_REG_MASK(VENC_VDAC_SETTING, 0x1f); switch_mod_gate_by_name("venc", 0); return 0; }
/* *power off the 656 module,clear the parameters */ static void am656in_feclose(struct tvin_frontend_s *fe) { struct am656in_dev_s *devp = container_of(fe, am656in_dev_t, frontend); enum tvin_port_e port = devp->para.port; if((port < TVIN_PORT_BT656)||(port > TVIN_PORT_CAMERA)){ printk("[bt656..]%s:invaild port %d.\n",__func__, port); return; } #ifdef CONFIG_ARCH_MESON6 switch_mod_gate_by_name("bt656", 0); #endif memset(&devp->para, 0, sizeof(vdin_parm_t)); }
static int ge2d_release(struct inode *inode, struct file *file) { ge2d_context_t *context=(ge2d_context_t *)file->private_data; if(context && (0==destroy_ge2d_work_queue(context))) { ge2d_device.open_count--; if (ge2d_device.open_count == 0) switch_mod_gate_by_name("ge2d", 0); return 0; } amlog_level(LOG_LEVEL_LOW,"release one ge2d device\n"); return -1; }
void osd_antiflicker_task_stop(void) { if (!ge2d_osd_antiflicker.inited) { printk("osd_antiflicker_task already stopped.\n"); return; } printk("osd_antiflicker_task stop.\n"); #if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6 switch_mod_gate_by_name("ge2d", 0); #endif if (ge2d_osd_antiflicker.ge2d_context) { destroy_ge2d_work_queue(ge2d_osd_antiflicker.ge2d_context); ge2d_osd_antiflicker.ge2d_context = NULL; } ge2d_osd_antiflicker.inited = false; }
static int ge2d_open(struct inode *inode, struct file *file) { ge2d_context_t *context; //we create one ge2d workqueue for this file handler. if (ge2d_device.open_count == 0) switch_mod_gate_by_name("ge2d", 1); if(NULL==(context=create_ge2d_work_queue())) { amlog_level(LOG_LEVEL_HIGH,"can't create work queue \r\n"); return -1; } //amlog_level(LOG_LEVEL_LOW,"open one ge2d device\n"); file->private_data=context; ge2d_device.open_count++; return 0; }
int osd_clone_task_start(void) { if (s_osd_clone.inited) { printk("osd_clone_task already started.\n"); return 0; } printk("osd_clone_task start.\n"); #if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6 switch_mod_gate_by_name("ge2d", 1); #endif if (s_osd_clone.ge2d_context == NULL) s_osd_clone.ge2d_context = create_ge2d_work_queue(); memset(&s_osd_clone.ge2d_config, 0, sizeof(config_para_ex_t)); s_osd_clone.inited = true; return 0; }
/* *power on 656 module&init the parameters,such as color fmt...,will be used by vdin */ static void am656in_feopen(struct tvin_frontend_s *fe, enum tvin_port_e port) { struct am656in_dev_s *am656_devp = container_of(fe, am656in_dev_t, frontend); struct vdin_parm_s *parm = fe->private_data; if((port < TVIN_PORT_BT656)||(port > TVIN_PORT_CAMERA)){ printk("[bt656..]%s:invaild port %d.\n",__func__, port); return; } /*copy the param from vdin to bt656*/ if(!memcpy(&am656_devp->para, parm, sizeof(vdin_parm_t))){ printk("[bt656..]%s memcpy error.\n",__func__); return; } printk("[bt656..] %s color format %s,hsync phase %u,vsync phase %u,"\ "frame rate %u,hs_bp %u,vs_bp %u.\n", __func__, tvin_color_fmt_str(parm->cfmt),parm->hsync_phase, parm->vsync_phase,parm->frame_rate,parm->hs_bp,parm->vs_bp); #ifdef CONFIG_ARCH_MESON6 switch_mod_gate_by_name("bt656", 1); #endif }
int tvoutc_setmode(tvmode_t mode) { const reg_t *s; if (mode >= TVMODE_MAX) { printk(KERN_ERR "Invalid video output modes.\n"); return -ENODEV; } #if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6 switch_mod_gate_by_name("venc", 1); #endif printk(KERN_DEBUG "TV mode %s selected.\n", tvinfoTab[mode].id); s = tvregsTab[mode]; while (MREG_END_MARKER != s->reg) setreg(s++); printk("%s[%d]\n", __func__, __LINE__); // if (mode < TVMODE_VGA) set_tvmode_misc(mode); #ifdef CONFIG_ARCH_MESON1 tvoutc_setclk(mode); printk("%s[%d]\n", __func__, __LINE__); enable_vsync_interrupt(); #endif #ifdef CONFIG_AM_TV_OUTPUT2 switch(mode) { case TVMODE_480I: case TVMODE_480CVBS: case TVMODE_576I: case TVMODE_576CVBS: WRITE_CBUS_REG_BITS(VPU_VIU_VENC_MUX_CTRL, 1, 0, 2); //reg0x271a, select ENCI to VIU1 WRITE_CBUS_REG_BITS(VPU_VIU_VENC_MUX_CTRL, 1, 4, 4); //reg0x271a, Select encI clock to VDIN WRITE_CBUS_REG_BITS(VPU_VIU_VENC_MUX_CTRL, 1, 8, 4); //reg0x271a,Enable VIU of ENC_I domain to VDIN; break; case TVMODE_480P: case TVMODE_576P: case TVMODE_720P: case TVMODE_720P_50HZ: case TVMODE_1080I: //?? case TVMODE_1080I_50HZ: //?? case TVMODE_1080P: case TVMODE_1080P_50HZ: WRITE_CBUS_REG_BITS(VPU_VIU_VENC_MUX_CTRL, 2, 0, 2); //reg0x271a, select ENCP to VIU1 WRITE_CBUS_REG_BITS(VPU_VIU_VENC_MUX_CTRL, 2, 4, 4); //reg0x271a, Select encP clock to VDIN WRITE_CBUS_REG_BITS(VPU_VIU_VENC_MUX_CTRL, 2, 8, 4); //reg0x271a,Enable VIU of ENC_P domain to VDIN; break; default: printk(KERN_ERR "unsupport tv mode,video clk is not set!!\n"); } #endif WRITE_MPEG_REG(VPP_POSTBLEND_H_SIZE, tvinfoTab[mode].xres); #ifdef CONFIG_ARCH_MESON3 printk(" clk_util_clk_msr 6 = %d\n", clk_util_clk_msr(6)); printk(" clk_util_clk_msr 7 = %d\n", clk_util_clk_msr(7)); printk(" clk_util_clk_msr 8 = %d\n", clk_util_clk_msr(8)); printk(" clk_util_clk_msr 9 = %d\n", clk_util_clk_msr(9)); printk(" clk_util_clk_msr 10 = %d\n", clk_util_clk_msr(10)); printk(" clk_util_clk_msr 27 = %d\n", clk_util_clk_msr(27)); printk(" clk_util_clk_msr 29 = %d\n", clk_util_clk_msr(29)); #endif //while(1); return 0; }
int clk_enable_usb(struct clk *clk) { int port_idx,i; char * clk_name; usb_peri_reg_t * peri_a,* peri_b,*peri; usb_config_data_t config; usb_ctrl_data_t control; //usb_dbg_uart_data_t uart; int clk_sel,clk_div,clk_src; int time_dly = 500; //usec if(!clk) return -1; clk_name = (char*)clk->priv; #if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6 switch_mod_gate_by_name(clk_name, 1); #endif peri_a = (usb_peri_reg_t *)P_USB_ADDR0; peri_b = (usb_peri_reg_t *)P_USB_ADDR8; if(!strcmp(clk_name,"usb0")){ peri = peri_a; port_idx = USB_PORT_IDX_A; }else if(!strcmp(clk_name,"usb1")){ peri = peri_b; port_idx = USB_PORT_IDX_B; }else{ printk(KERN_ERR "bad usb clk name: %s\n",clk_name); return -1; } if(!init_count){ init_count++; aml_set_reg32_bits(P_RESET1_REGISTER, 1, 2, 1); for(i = 0; i < 1000; i++) udelay(time_dly); clk_sel = USB_PHY_CLK_SEL_XTAL; clk_div = 1; clk_src = 24000000; config.d32 = peri_a->config; config.b.clk_sel = clk_sel; config.b.clk_div = clk_div; config.b.clk_en = 1; peri_a->config = config.d32; config.d32 = peri_b->config; config.b.clk_sel = clk_sel; config.b.clk_div = clk_div; config.b.clk_en = 1; peri_b->config = config.d32; printk(KERN_NOTICE"USB (%d) use clock source: %s\n",port_idx,clock_src_name[clk_sel]); control.d32 = peri_b->ctrl; control.b.fsel = 2; /* PHY default is 24M (5), change to 12M (2) */ control.b.por = 1; peri_b->ctrl = control.d32; control.d32 = peri_a->ctrl; control.b.fsel = 2; /* PHY default is 24M (5), change to 12M (2) */ control.b.por = 1; peri_a->ctrl = control.d32; udelay(time_dly); control.b.por = 0; peri_a->ctrl = control.d32; udelay(time_dly); /* read back clock detected flag*/ control.d32 = peri_a->ctrl; if(!control.b.clk_detected){ printk(KERN_ERR"USB (%d) PHY Clock not detected!\n",0); } control.d32 = peri_b->ctrl; if(!control.b.clk_detected){ printk(KERN_ERR"USB (%d) PHY Clock not detected!\n",1); } } //uart.d32 = peri->dbg_uart; //uart.b.set_iddq = 0; //peri->dbg_uart = uart.d32; dmb(); return 0; }
int clk_enable_usb(struct clk *clk) { int port_idx; char * clk_name; usb_peri_reg_t * peri_a,* peri_b,*peri; usb_config_data_t config; usb_ctrl_data_t control; usb_adp_bc_data_t adp_bc; int clk_sel,clk_div,clk_src; int time_dly = 500; //usec if(!clk) return -1; if(!init_count) { init_count++; aml_set_reg32_bits(P_RESET1_REGISTER, 1, 2, 1); //for(i = 0; i < 1000; i++) // udelay(time_dly); } clk_name = (char*)clk->priv; switch_mod_gate_by_name(clk_name, 1); peri_a = (usb_peri_reg_t *)P_USB_ADDR0; peri_b = (usb_peri_reg_t *)P_USB_ADDR8; if(!strcmp(clk_name,"usb0")){ peri = peri_a; port_idx = USB_PORT_IDX_A; }else if(!strcmp(clk_name,"usb1")){ peri = peri_b; port_idx = USB_PORT_IDX_B; }else{ printk(KERN_ERR "bad usb clk name: %s\n",clk_name); return -1; } clk_sel = USB_PHY_CLK_SEL_XTAL; clk_div = 1; clk_src = 24000000; config.d32 = peri->config; config.b.clk_32k_alt_sel= 1; peri->config = config.d32; printk(KERN_NOTICE"USB (%d) use clock source: %s\n",port_idx,clock_src_name[clk_sel]); control.d32 = peri->ctrl; control.b.fsel = 5;//2; /* PHY default is 24M (5), change to 12M (2) */ control.b.por = 1; peri->ctrl = control.d32; udelay(time_dly); control.b.por = 0; peri->ctrl = control.d32; udelay(time_dly); /* read back clock detected flag*/ control.d32 = peri->ctrl; if(!control.b.clk_detected){ printk(KERN_ERR"USB (%d) PHY Clock not detected!\n",port_idx); } /* force ACA enable */ if(IS_MESON_M8M2_CPU && port_idx == USB_PORT_IDX_B){ adp_bc.d32 = peri->adp_bc; adp_bc.b.aca_enable = 1; peri->adp_bc = adp_bc.d32; udelay(50); adp_bc.d32 = peri->adp_bc; if(adp_bc.b.aca_pin_float){ printk(KERN_ERR "USB-B ID detect failed!\n"); printk(KERN_ERR "Please use the chip after version RevA1!\n"); return -1; } } dmb(); return 0; }
int video_dac_enable(unsigned char enable_mask) { switch_mod_gate_by_name("venc", 1); CLEAR_CBUS_REG_MASK(VENC_VDAC_SETTING, enable_mask & 0x1f); return 0; }
/** * stmmac_pltfr_probe * @pdev: platform device pointer * Description: platform_device probe function. It allocates * the necessary resources and invokes the main to init * the net device, register the mdio bus etc. */ static int stmmac_pltfr_probe(struct platform_device *pdev) { int ret = 0; //addr =phys_to_virt(); struct resource *res; struct device *dev = &pdev->dev; void __iomem *addr = NULL; struct stmmac_priv *priv = NULL; struct plat_stmmacenet_data *plat_dat = NULL; const char *mac = NULL; #ifdef CONFIG_DWMAC_MESON switch_mod_gate_by_name("ethernet",1); #endif res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENODEV; addr = devm_ioremap_resource(dev, res); //addr = ( void* )(0xfe0c0000); printk("ethernet base addr is %x\n", (unsigned int)addr); plat_dat = dev_get_platdata(&pdev->dev); if (pdev->dev.of_node) { if (!plat_dat) plat_dat = devm_kzalloc(&pdev->dev, sizeof(struct plat_stmmacenet_data), GFP_KERNEL); if (!plat_dat) { pr_err("%s: ERROR: no memory", __func__); return -ENOMEM; } ret = stmmac_probe_config_dt(pdev, plat_dat, &mac); if (ret) { pr_err("%s: main dt probe failed", __func__); return ret; } } /* Custom setup (if needed) */ if (plat_dat->setup) { plat_dat->bsp_priv = plat_dat->setup(pdev); if (IS_ERR(plat_dat->bsp_priv)) return PTR_ERR(plat_dat->bsp_priv); } /* Custom initialisation (if needed)*/ if (plat_dat->init) { ret = plat_dat->init(pdev, plat_dat->bsp_priv); if (unlikely(ret)) return ret; } priv = stmmac_dvr_probe(&(pdev->dev), plat_dat, addr); if (IS_ERR(priv)) { pr_err("%s: main driver probe failed", __func__); return PTR_ERR(priv); } /* Get MAC address if available (DT) */ if (mac) memcpy(priv->dev->dev_addr, mac, ETH_ALEN); /* Get the MAC information */ priv->dev->irq = platform_get_irq_byname(pdev, "macirq"); if (priv->dev->irq < 0) { if (priv->dev->irq != -EPROBE_DEFER) { netdev_err(priv->dev, "MAC IRQ configuration information not found\n"); } return priv->dev->irq; } /* * On some platforms e.g. SPEAr the wake up irq differs from the mac irq * The external wake up irq can be passed through the platform code * named as "eth_wake_irq" * * In case the wake up interrupt is not passed from the platform * so the driver will continue to use the mac irq (ndev->irq) */ priv->wol_irq = platform_get_irq_byname(pdev, "eth_wake_irq"); if (priv->wol_irq < 0) { if (priv->wol_irq == -EPROBE_DEFER) return -EPROBE_DEFER; priv->wol_irq = priv->dev->irq; } priv->lpi_irq = platform_get_irq_byname(pdev, "eth_lpi"); if (priv->lpi_irq == -EPROBE_DEFER) return -EPROBE_DEFER; platform_set_drvdata(pdev, priv->dev); pr_debug("STMMAC platform driver registration completed"); return 0; }