Skip to content

Commit

Permalink
viafb: Move core stuff into via-core.c
Browse files Browse the repository at this point in the history
The first step toward turning viafb into a multifunction driver.  This
patch creates a new via-core.c file which serves as the main PCI driver;
everything else comes below that.  Some work has been done to rationalize
the i2c drivers in this new scheme.

Cc: ScottFang@viatech.com.cn
Cc: JosephChan@via.com.tw
Cc: Harald Welte <laforge@gnumonks.org>
Acked-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
  • Loading branch information
Jonathan Corbet committed May 7, 2010
1 parent 4da62e6 commit f045f77
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 132 deletions.
2 changes: 1 addition & 1 deletion drivers/video/via/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

obj-$(CONFIG_FB_VIA) += viafb.o

viafb-y :=viafbdev.o hw.o via_i2c.o dvi.o lcd.o ioctl.o accel.o via_utility.o vt1636.o global.o tblDPASetting.o viamode.o tbl1636.o
viafb-y :=viafbdev.o hw.o via_i2c.o dvi.o lcd.o ioctl.o accel.o via_utility.o vt1636.o global.o tblDPASetting.o viamode.o tbl1636.o via-core.o
4 changes: 2 additions & 2 deletions drivers/video/via/dvi.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ int viafb_tmds_trasmitter_identify(void)
viaparinfo->chip_info->tmds_chip_info.tmds_chip_name = VT1632_TMDS;
viaparinfo->chip_info->
tmds_chip_info.tmds_chip_slave_addr = VT1632_TMDS_I2C_ADDR;
viaparinfo->chip_info->tmds_chip_info.i2c_port = VIA_I2C_ADAP_31;
viaparinfo->chip_info->tmds_chip_info.i2c_port = VIA_PORT_31;
if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID) != FAIL) {
/*
* Currently only support 12bits,dual edge,add 24bits mode later
Expand All @@ -110,7 +110,7 @@ int viafb_tmds_trasmitter_identify(void)
viaparinfo->chip_info->tmds_chip_info.i2c_port);
return OK;
} else {
viaparinfo->chip_info->tmds_chip_info.i2c_port = VIA_I2C_ADAP_2C;
viaparinfo->chip_info->tmds_chip_info.i2c_port = VIA_PORT_2C;
if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID)
!= FAIL) {
tmds_register_write(0x08, 0x3b);
Expand Down
1 change: 1 addition & 0 deletions drivers/video/via/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

#include "debug.h"

#include "via-core.h"
#include "viafbdev.h"
#include "chip.h"
#include "accel.h"
Expand Down
10 changes: 5 additions & 5 deletions drivers/video/via/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ static bool lvds_identify_integratedlvds(void)

int viafb_lvds_trasmitter_identify(void)
{
if (viafb_lvds_identify_vt1636(VIA_I2C_ADAP_31)) {
viaparinfo->chip_info->lvds_chip_info.i2c_port = VIA_I2C_ADAP_31;
if (viafb_lvds_identify_vt1636(VIA_PORT_31)) {
viaparinfo->chip_info->lvds_chip_info.i2c_port = VIA_PORT_31;
DEBUG_MSG(KERN_INFO
"Found VIA VT1636 LVDS on port i2c 0x31\n");
} else {
if (viafb_lvds_identify_vt1636(VIA_I2C_ADAP_2C)) {
if (viafb_lvds_identify_vt1636(VIA_PORT_2C)) {
viaparinfo->chip_info->lvds_chip_info.i2c_port =
VIA_I2C_ADAP_2C;
VIA_PORT_2C;
DEBUG_MSG(KERN_INFO
"Found VIA VT1636 LVDS on port gpio 0x2c\n");
}
Expand Down Expand Up @@ -419,7 +419,7 @@ static int lvds_register_read(int index)
{
u8 data;

viafb_i2c_readbyte(VIA_I2C_ADAP_2C,
viafb_i2c_readbyte(VIA_PORT_2C,
(u8) viaparinfo->chip_info->lvds_chip_info.lvds_chip_slave_addr,
(u8) index, &data);
return data;
Expand Down
116 changes: 116 additions & 0 deletions drivers/video/via/via-core.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
* Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved.
* Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
* Copyright 2009 Jonathan Corbet <corbet@lwn.net>
*/

/*
* Core code for the Via multifunction framebuffer device.
*/
#include <linux/module.h>
#include <linux/platform_device.h>
#include "global.h" /* Includes everything under the sun */

/*
* The default port config.
*/
static struct via_port_cfg adap_configs[] = {
[VIA_PORT_26] = { VIA_PORT_I2C, VIA_MODE_OFF, VIASR, 0x26 },
[VIA_PORT_31] = { VIA_PORT_I2C, VIA_MODE_I2C, VIASR, 0x31 },
[VIA_PORT_25] = { VIA_PORT_GPIO, VIA_MODE_GPIO, VIASR, 0x25 },
[VIA_PORT_2C] = { VIA_PORT_GPIO, VIA_MODE_I2C, VIASR, 0x2c },
[VIA_PORT_3D] = { VIA_PORT_GPIO, VIA_MODE_GPIO, VIASR, 0x3d },
{ 0, 0, 0, 0 }
};


static int __devinit via_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
int ret;

ret = pci_enable_device(pdev);
if (ret)
return ret;
/*
* Create the I2C busses. Bailing out on failure seems extreme,
* but that's what the code did before.
*/
ret = viafb_create_i2c_busses(adap_configs);
if (ret)
goto out_disable;
/*
* Set up the framebuffer.
*/
ret = via_fb_pci_probe(pdev, ent);
if (ret)
goto out_i2c;
return 0;

out_i2c:
viafb_delete_i2c_busses();
out_disable:
pci_disable_device(pdev);
return ret;
}

static void __devexit via_pci_remove(struct pci_dev *pdev)
{
viafb_delete_i2c_busses();
via_fb_pci_remove(pdev);
pci_disable_device(pdev);
}


static struct pci_device_id via_pci_table[] __devinitdata = {
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CLE266_DID),
.driver_data = UNICHROME_CLE266 },
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_PM800_DID),
.driver_data = UNICHROME_PM800 },
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K400_DID),
.driver_data = UNICHROME_K400 },
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K800_DID),
.driver_data = UNICHROME_K800 },
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_P4M890_DID),
.driver_data = UNICHROME_CN700 },
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_K8M890_DID),
.driver_data = UNICHROME_K8M890 },
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CX700_DID),
.driver_data = UNICHROME_CX700 },
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_P4M900_DID),
.driver_data = UNICHROME_P4M900 },
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_CN750_DID),
.driver_data = UNICHROME_CN750 },
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX800_DID),
.driver_data = UNICHROME_VX800 },
{ PCI_DEVICE(PCI_VENDOR_ID_VIA, UNICHROME_VX855_DID),
.driver_data = UNICHROME_VX855 },
{ }
};
MODULE_DEVICE_TABLE(pci, via_pci_table);

static struct pci_driver via_driver = {
.name = "viafb",
.id_table = via_pci_table,
.probe = via_pci_probe,
.remove = __devexit_p(via_pci_remove),
};

static int __init via_core_init(void)
{
int ret;

ret = viafb_init();
if (ret)
return ret;
return pci_register_driver(&via_driver);
}

static void __exit via_core_exit(void)
{
pci_unregister_driver(&via_driver);
viafb_exit();
}

module_init(via_core_init);
module_exit(via_core_exit);
55 changes: 55 additions & 0 deletions drivers/video/via/via-core.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 1998-2009 VIA Technologies, Inc. All Rights Reserved.
* Copyright 2001-2008 S3 Graphics, Inc. All Rights Reserved.
* Copyright 2009 Jonathan Corbet <corbet@lwn.net>
*
* 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, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE.See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifndef __VIA_CORE_H__
#define __VIA_CORE_H__
/*
* A description of each known serial I2C/GPIO port.
*/
enum via_port_type {
VIA_PORT_NONE = 0,
VIA_PORT_I2C,
VIA_PORT_GPIO,
};

enum via_port_mode {
VIA_MODE_OFF = 0,
VIA_MODE_I2C, /* Used as I2C port */
VIA_MODE_GPIO, /* Two GPIO ports */
};

enum viafb_i2c_adap {
VIA_PORT_26 = 0,
VIA_PORT_31,
VIA_PORT_25,
VIA_PORT_2C,
VIA_PORT_3D,
};
#define VIAFB_NUM_PORTS 5

struct via_port_cfg {
enum via_port_type type;
enum via_port_mode mode;
u_int16_t io_port;
u_int8_t ioport_index;
};
#endif /* __VIA_CORE_H__ */
Loading

0 comments on commit f045f77

Please sign in to comment.