H A D | cafe-driver.c | 35 #include "mcam-core.h" 53 struct mcam_camera mcam; member in struct:cafe_camera 59 * Most of the camera controller registers are defined in mcam-core.h, 147 return container_of(m, struct cafe_camera, mcam); to_cam() 151 static int cafe_smbus_write_done(struct mcam_camera *mcam) cafe_smbus_write_done() argument 162 spin_lock_irqsave(&mcam->dev_lock, flags); cafe_smbus_write_done() 163 c1 = mcam_reg_read(mcam, REG_TWSIC1); cafe_smbus_write_done() 164 spin_unlock_irqrestore(&mcam->dev_lock, flags); cafe_smbus_write_done() 173 struct mcam_camera *mcam = &cam->mcam; cafe_smbus_write_data() local 175 spin_lock_irqsave(&mcam->dev_lock, flags); cafe_smbus_write_data() 182 mcam_reg_write(mcam, REG_TWSIC0, rval); cafe_smbus_write_data() 183 (void) mcam_reg_read(mcam, REG_TWSIC1); /* force write */ cafe_smbus_write_data() 185 mcam_reg_write(mcam, REG_TWSIC1, rval); cafe_smbus_write_data() 186 spin_unlock_irqrestore(&mcam->dev_lock, flags); cafe_smbus_write_data() 206 wait_event_timeout(cam->smbus_wait, cafe_smbus_write_done(mcam), cafe_smbus_write_data() 209 spin_lock_irqsave(&mcam->dev_lock, flags); cafe_smbus_write_data() 210 rval = mcam_reg_read(mcam, REG_TWSIC1); cafe_smbus_write_data() 211 spin_unlock_irqrestore(&mcam->dev_lock, flags); cafe_smbus_write_data() 228 static int cafe_smbus_read_done(struct mcam_camera *mcam) cafe_smbus_read_done() argument 239 spin_lock_irqsave(&mcam->dev_lock, flags); cafe_smbus_read_done() 240 c1 = mcam_reg_read(mcam, REG_TWSIC1); cafe_smbus_read_done() 241 spin_unlock_irqrestore(&mcam->dev_lock, flags); cafe_smbus_read_done() 252 struct mcam_camera *mcam = &cam->mcam; cafe_smbus_read_data() local 254 spin_lock_irqsave(&mcam->dev_lock, flags); cafe_smbus_read_data() 261 mcam_reg_write(mcam, REG_TWSIC0, rval); cafe_smbus_read_data() 262 (void) mcam_reg_read(mcam, REG_TWSIC1); /* force write */ cafe_smbus_read_data() 264 mcam_reg_write(mcam, REG_TWSIC1, rval); cafe_smbus_read_data() 265 spin_unlock_irqrestore(&mcam->dev_lock, flags); cafe_smbus_read_data() 268 cafe_smbus_read_done(mcam), CAFE_SMBUS_TIMEOUT); cafe_smbus_read_data() 269 spin_lock_irqsave(&mcam->dev_lock, flags); cafe_smbus_read_data() 270 rval = mcam_reg_read(mcam, REG_TWSIC1); cafe_smbus_read_data() 271 spin_unlock_irqrestore(&mcam->dev_lock, flags); cafe_smbus_read_data() 318 spin_lock_irqsave(&cam->mcam.dev_lock, flags); cafe_smbus_enable_irq() 319 mcam_reg_set_bit(&cam->mcam, REG_IRQMASK, TWSIIRQS); cafe_smbus_enable_irq() 320 spin_unlock_irqrestore(&cam->mcam.dev_lock, flags); cafe_smbus_enable_irq() 354 cam->mcam.i2c_adapter = adap; cafe_smbus_setup() 361 i2c_del_adapter(cam->mcam.i2c_adapter); cafe_smbus_shutdown() 362 kfree(cam->mcam.i2c_adapter); cafe_smbus_shutdown() 370 static void cafe_ctlr_init(struct mcam_camera *mcam) cafe_ctlr_init() argument 374 spin_lock_irqsave(&mcam->dev_lock, flags); cafe_ctlr_init() 378 mcam_reg_write(mcam, 0x3038, 0x8); cafe_ctlr_init() 379 mcam_reg_write(mcam, 0x315c, 0x80008); cafe_ctlr_init() 386 mcam_reg_write(mcam, REG_GL_CSR, GCSR_SRS|GCSR_MRS); /* Needed? */ cafe_ctlr_init() 387 mcam_reg_write(mcam, REG_GL_CSR, GCSR_SRC|GCSR_MRC); cafe_ctlr_init() 388 mcam_reg_write(mcam, REG_GL_CSR, GCSR_SRC|GCSR_MRS); cafe_ctlr_init() 392 spin_unlock_irqrestore(&mcam->dev_lock, flags); cafe_ctlr_init() 394 spin_lock_irqsave(&mcam->dev_lock, flags); cafe_ctlr_init() 396 mcam_reg_write(mcam, REG_GL_CSR, GCSR_CCIC_EN|GCSR_SRC|GCSR_MRC); cafe_ctlr_init() 397 mcam_reg_set_bit(mcam, REG_GL_IMASK, GIMSK_CCIC_EN); cafe_ctlr_init() 401 mcam_reg_write(mcam, REG_IRQMASK, 0); cafe_ctlr_init() 402 spin_unlock_irqrestore(&mcam->dev_lock, flags); cafe_ctlr_init() 406 static int cafe_ctlr_power_up(struct mcam_camera *mcam) cafe_ctlr_power_up() argument 412 mcam_reg_write(mcam, REG_GL_FCR, GFCR_GPIO_ON); cafe_ctlr_power_up() 413 mcam_reg_write(mcam, REG_GL_GPIOR, GGPIO_OUT|GGPIO_VAL); cafe_ctlr_power_up() 419 mcam_reg_write(mcam, REG_GPR, GPR_C1EN|GPR_C0EN); /* pwr up, reset */ cafe_ctlr_power_up() 420 mcam_reg_write(mcam, REG_GPR, GPR_C1EN|GPR_C0EN|GPR_C0); cafe_ctlr_power_up() 425 static void cafe_ctlr_power_down(struct mcam_camera *mcam) cafe_ctlr_power_down() argument 427 mcam_reg_write(mcam, REG_GPR, GPR_C1EN|GPR_C0EN|GPR_C1); cafe_ctlr_power_down() 428 mcam_reg_write(mcam, REG_GL_FCR, GFCR_GPIO_ON); cafe_ctlr_power_down() 429 mcam_reg_write(mcam, REG_GL_GPIOR, GGPIO_OUT); cafe_ctlr_power_down() 440 struct mcam_camera *mcam = &cam->mcam; cafe_irq() local 443 spin_lock(&mcam->dev_lock); cafe_irq() 444 irqs = mcam_reg_read(mcam, REG_IRQSTAT); cafe_irq() 445 handled = cam->registered && mccic_irq(mcam, irqs); cafe_irq() 447 mcam_reg_write(mcam, REG_IRQSTAT, TWSIIRQS); cafe_irq() 451 spin_unlock(&mcam->dev_lock); cafe_irq() 466 struct mcam_camera *mcam; cafe_pci_probe() local 476 mcam = &cam->mcam; cafe_pci_probe() 477 mcam->chip_id = MCAM_CAFE; cafe_pci_probe() 478 spin_lock_init(&mcam->dev_lock); cafe_pci_probe() 480 mcam->plat_power_up = cafe_ctlr_power_up; cafe_pci_probe() 481 mcam->plat_power_down = cafe_ctlr_power_down; cafe_pci_probe() 482 mcam->dev = &pdev->dev; cafe_pci_probe() 483 snprintf(mcam->bus_info, sizeof(mcam->bus_info), "PCI:%s", pci_name(pdev)); cafe_pci_probe() 488 mcam->clock_speed = 45; cafe_pci_probe() 489 mcam->use_smbus = 1; cafe_pci_probe() 495 mcam->buffer_mode = B_vmalloc; cafe_pci_probe() 505 mcam->regs = pci_iomap(pdev, 0, 0); cafe_pci_probe() 506 if (!mcam->regs) { cafe_pci_probe() 510 mcam->regs_size = pci_resource_len(pdev, 0); cafe_pci_probe() 519 cafe_ctlr_init(mcam); cafe_pci_probe() 520 cafe_ctlr_power_up(mcam); cafe_pci_probe() 530 ret = mccic_register(mcam); cafe_pci_probe() 538 cafe_ctlr_power_down(mcam); cafe_pci_probe() 541 pci_iounmap(pdev, mcam->regs); cafe_pci_probe() 556 mccic_shutdown(&cam->mcam); cafe_shutdown() 559 pci_iounmap(cam->pdev, cam->mcam.regs); cafe_shutdown() 590 mccic_suspend(&cam->mcam); cafe_pci_suspend() 609 cafe_ctlr_init(&cam->mcam); cafe_pci_resume() 610 return mccic_resume(&cam->mcam); cafe_pci_resume()
|