feat(camera): support GalaxyCore GC2385 (TA-1059) and GC2365 alongside GC2395 (TA-1048)

This commit is contained in:
Luxferre committed 2026-10-27 18:28:32 +02:00
1 parent a2b8e46c43
commit eef8584a8d
8 files changed
+109 -28

No files matched your search

+99 -19
View File
@@ -2,7 +2,8 @@
/*
* Qualcomm MSM8905 / Nokia 8110 4G (nokia-argon) Rear Camera V4L2 Driver
*
* Drives the GalaxyCore GC2395 2MP MIPI CSI-2 sensor on BLSP1 I2C3 (GPIO 29/30)
* Drives the GalaxyCore GC2395 (TA-1048), GC2385 (TA-1059), and GC2365 2MP
* MIPI CSI-2 sensors on BLSP1 I2C3 (GPIO 29/30)
* through MSM8909 CAMSS (CSIPHY0 -> CSID0 -> ISPIF RDI0 -> VFE0 WM0 -> VBIF)
* and exposes /dev/video0 (800x600 RGB24 V4L2 capture device).
*/
@@ -71,11 +72,16 @@
#define ISPIF_BASE 0x0a000U
#define VFE0_BASE 0x10000U
#define GC2395_CHIP_ID 0x2395U
#define GC2385_CHIP_ID 0x2385U
#define GC2365_CHIP_ID 0x2365U
struct gc2395_reg {
u8 reg;
u8 val;
};
/* Shared 1600x1200 RAW10 MIPI CSI-2 init table for GC2395 (TA-1048) and GC2385 (TA-1059) */
static const struct gc2395_reg gc2395_init_regs[] = {
{ 0xfe, 0x00 }, { 0xfe, 0x00 }, { 0xfe, 0x00 }, { 0xf2, 0x02 },
{ 0xf4, 0x03 }, { 0xf7, 0x01 }, { 0xf8, 0x28 }, { 0xf9, 0x02 },
@@ -100,6 +106,41 @@ static const struct gc2395_reg gc2395_init_regs[] = {
{ 0x29, 0x06 }, { 0x2a, 0x08 }, { 0x2b, 0x06 }, { 0xfe, 0x00 },
};
/* 1600x1200 RAW10 MIPI CSI-2 init table for GC2365 */
static const struct gc2395_reg gc2365_init_regs[] = {
{ 0xfe, 0x00 }, { 0xfe, 0x00 }, { 0xfe, 0x00 }, { 0xf7, 0x01 },
{ 0xf8, 0x0d }, { 0xf9, 0x4a }, { 0xfa, 0x80 }, { 0xfc, 0x8e },
{ 0xfe, 0x00 }, { 0xfe, 0x00 }, { 0xfe, 0x00 }, { 0x88, 0x03 },
{ 0xfe, 0x00 }, { 0x03, 0x04 }, { 0x04, 0x62 }, { 0x05, 0x02 },
{ 0x06, 0xbc }, { 0x07, 0x02 }, { 0x08, 0x00 }, { 0x0a, 0x0a },
{ 0x0c, 0x12 }, { 0x0d, 0x04 }, { 0x0e, 0xb8 }, { 0x0f, 0x06 },
{ 0x10, 0x50 }, { 0x17, 0xc0 }, { 0x1b, 0x11 }, { 0x1d, 0x0f },
{ 0x1f, 0x16 }, { 0x22, 0x50 }, { 0x27, 0x76 }, { 0x2b, 0x28 },
{ 0x2c, 0x40 }, { 0x2e, 0x8f }, { 0x2f, 0xd5 }, { 0x32, 0x05 },
{ 0x33, 0x50 }, { 0x37, 0x28 }, { 0x38, 0x50 }, { 0x39, 0x80 },
{ 0x3d, 0x18 }, { 0x3e, 0x1d }, { 0x3f, 0x50 }, { 0x75, 0x8e },
{ 0x76, 0x08 }, { 0x77, 0x5d }, { 0x78, 0x09 }, { 0x79, 0xb3 },
{ 0x7a, 0x24 }, { 0x8a, 0x3f }, { 0xc0, 0xb0 }, { 0xc1, 0x13 },
{ 0xc2, 0x00 }, { 0xc3, 0x2c }, { 0xc4, 0x4b }, { 0xe0, 0x02 },
{ 0xe1, 0x02 }, { 0xe2, 0x02 }, { 0xe3, 0x02 }, { 0xe4, 0x02 },
{ 0xe5, 0x02 }, { 0xe6, 0x02 }, { 0xe7, 0x02 }, { 0xe8, 0x07 },
{ 0x28, 0xf0 }, { 0x90, 0x01 }, { 0x92, 0x03 }, { 0x94, 0x02 },
{ 0x95, 0x04 }, { 0x96, 0xb0 }, { 0x97, 0x06 }, { 0x98, 0x40 },
{ 0x18, 0x02 }, { 0x40, 0x22 }, { 0x41, 0x01 }, { 0x43, 0x07 },
{ 0x4c, 0x00 }, { 0x4d, 0x03 }, { 0x4e, 0x3c }, { 0x4f, 0x3c },
{ 0x60, 0x00 }, { 0x61, 0x80 }, { 0x84, 0x00 }, { 0x85, 0x20 },
{ 0x87, 0x30 }, { 0xa0, 0x01 }, { 0xa1, 0x02 }, { 0xbd, 0x01 },
{ 0xbe, 0x02 }, { 0xb0, 0x60 }, { 0xb1, 0x02 }, { 0xb2, 0x80 },
{ 0xb3, 0x40 }, { 0xb4, 0x40 }, { 0xb5, 0x40 }, { 0xb6, 0x00 },
{ 0x66, 0xc7 }, { 0x72, 0xff }, { 0x74, 0xff }, { 0xfe, 0x03 },
{ 0x10, 0x00 }, { 0x01, 0x03 }, { 0x02, 0x32 }, { 0x03, 0x90 },
{ 0x04, 0x04 }, { 0x05, 0x00 }, { 0x06, 0x80 }, { 0x11, 0x2b },
{ 0x12, 0xd0 }, { 0x13, 0x07 }, { 0x15, 0x00 }, { 0x21, 0x08 },
{ 0x22, 0x05 }, { 0x23, 0x13 }, { 0x24, 0x02 }, { 0x25, 0x13 },
{ 0x26, 0x08 }, { 0x29, 0x04 }, { 0x2a, 0x08 }, { 0x2b, 0x08 },
{ 0xfe, 0x00 },
};
static const u32 camss_cbcr_offsets[] = {
0x56004U, 0x5a014U, 0x50004U,
0x58038U, 0x58044U, 0x58048U, 0x58050U,
@@ -127,6 +168,7 @@ struct msm8905_cam_dev {
bool buf_queued[CAM_MAX_MMAP_BUFS];
u32 num_bufs;
u32 sequence;
u16 chip_id;
bool streaming;
bool hw_initialized;
};
@@ -314,6 +356,31 @@ static void gc2395_write_reg(struct msm8905_cam_dev *cam, u8 reg, u8 val)
cam_i2c_stop(cam);
}
static void gc23xx_stream_on(struct msm8905_cam_dev *cam)
{
if (cam->chip_id == GC2365_CHIP_ID) {
gc2395_write_reg(cam, 0xfeU, 0x03U);
gc2395_write_reg(cam, 0x10U, 0x90U);
gc2395_write_reg(cam, 0xfeU, 0x00U);
} else {
gc2395_write_reg(cam, 0xfeU, 0x00U);
gc2395_write_reg(cam, 0xedU, 0x90U);
gc2395_write_reg(cam, 0xfeU, 0x00U);
}
}
static void gc23xx_stream_off(struct msm8905_cam_dev *cam)
{
if (cam->chip_id == GC2365_CHIP_ID) {
gc2395_write_reg(cam, 0xfeU, 0x03U);
gc2395_write_reg(cam, 0x10U, 0x00U);
gc2395_write_reg(cam, 0xfeU, 0x00U);
} else {
gc2395_write_reg(cam, 0xfeU, 0x00U);
gc2395_write_reg(cam, 0xedU, 0x00U);
}
}
static void msm8905_cam_enable_clocks(struct msm8905_cam_dev *cam)
{
size_t i;
@@ -372,7 +439,7 @@ static int msm8905_cam_hw_init(struct msm8905_cam_dev *cam)
for (i = 0; i < ARRAY_SIZE(camss_cbcr_offsets); i++)
cam_enable_cbcr(cam, camss_cbcr_offsets[i]);
/* 4. Power on GC2395 sensor */
/* 4. Power on GalaxyCore GC2395 / GC2385 / GC2365 sensor */
cam_gpio_cfg(cam, GPIO_CAM_STANDBY, 0x200U);
cam_gpio_cfg(cam, GPIO_CAM_RESET, 0x200U);
cam_gpio_cfg(cam, GPIO_CAM_VDIG, 0x200U);
@@ -386,13 +453,23 @@ static int msm8905_cam_hw_init(struct msm8905_cam_dev *cam)
usleep_range(15000, 18000);
chip_id = ((u16)gc2395_read_reg(cam, 0xf0U) << 8) | gc2395_read_reg(cam, 0xf1U);
if (chip_id != 0x2395U) {
dev_err(&cam->pdev->dev, "GC2395 chip ID mismatch: 0x%04x\n", chip_id);
if (chip_id != GC2395_CHIP_ID && chip_id != GC2385_CHIP_ID &&
chip_id != GC2365_CHIP_ID) {
dev_err(&cam->pdev->dev,
"GalaxyCore chip ID mismatch: 0x%04x (expected 0x2395/0x2385/0x2365)\n",
chip_id);
return -ENODEV;
}
cam->chip_id = chip_id;
dev_info(&cam->pdev->dev, "detected GalaxyCore GC%04x sensor\n", chip_id);
for (i = 0; i < ARRAY_SIZE(gc2395_init_regs); i++)
gc2395_write_reg(cam, gc2395_init_regs[i].reg, gc2395_init_regs[i].val);
if (chip_id == GC2365_CHIP_ID) {
for (i = 0; i < ARRAY_SIZE(gc2365_init_regs); i++)
gc2395_write_reg(cam, gc2365_init_regs[i].reg, gc2365_init_regs[i].val);
} else {
for (i = 0; i < ARRAY_SIZE(gc2395_init_regs); i++)
gc2395_write_reg(cam, gc2395_init_regs[i].reg, gc2395_init_regs[i].val);
}
/* 5. CSI_CLK_MUX */
cam_w32(cam->camss_base, 0x0030U, 0x0U);
@@ -523,11 +600,10 @@ static int msm8905_cam_capture_rgb(struct msm8905_cam_dev *cam, u8 *dst_rgb)
msm8905_cam_enable_clocks(cam);
}
/* Ensure GC2395 stream and ISPIF/VFE0 are idle before arming next frame */
/* Ensure sensor MIPI stream and ISPIF/VFE0 are idle before arming next frame */
cam_w32(cam->camss_base, ISPIF_BASE + 0x248U, 0xaaaaaaaaU);
wmb();
gc2395_write_reg(cam, 0xfeU, 0x00U);
gc2395_write_reg(cam, 0xedU, 0x00U);
gc23xx_stream_off(cam);
usleep_range(600, 900);
cam_w32(cam->camss_base, VFE0_BASE + 0x04cU, 0x00000000U);
cam_w32(cam->camss_base, VFE0_BASE + 0x6fcU, 0x00000000U);
@@ -564,13 +640,11 @@ static int msm8905_cam_capture_rgb(struct msm8905_cam_dev *cam, u8 *dst_rgb)
cam_w32(cam->camss_base, VFE0_BASE + 0x018U, 0x00000001U);
cam_w32(cam->camss_base, VFE0_BASE + 0x260U, 0x00000002U);
/* Enable ISPIF RDI0 on frame boundary and start GC2395 MIPI stream */
/* Enable ISPIF RDI0 on frame boundary and start sensor MIPI stream */
cam_w32(cam->camss_base, ISPIF_BASE + 0x248U, 0xfffffdffU);
wmb();
gc2395_write_reg(cam, 0xfeU, 0x00U);
gc2395_write_reg(cam, 0xedU, 0x90U);
gc2395_write_reg(cam, 0xfeU, 0x00U);
gc23xx_stream_on(cam);
/*
* Poll for WM0 PING_PONG_IRQ (bit 6 = 0x40) with sub-millisecond sleep so we
@@ -586,14 +660,13 @@ static int msm8905_cam_capture_rgb(struct msm8905_cam_dev *cam, u8 *dst_rgb)
/*
* 1. Gate ISPIF at frame boundary FIRST so VFE0 never receives a partial frame.
* 2. Stop GC2395 MIPI stream during VBLANK (LP-11 state).
* 2. Stop sensor MIPI stream during VBLANK (LP-11 state).
* 3. Wait for VFE0 WM0 / VBIF AXI write bursts to drain completely before
* clearing WM0_CFG and RDI0_CFG.
*/
cam_w32(cam->camss_base, ISPIF_BASE + 0x248U, 0xaaaaaaaaU);
wmb();
gc2395_write_reg(cam, 0xfeU, 0x00U);
gc2395_write_reg(cam, 0xedU, 0x00U);
gc23xx_stream_off(cam);
usleep_range(800, 1200);
cam_w32(cam->camss_base, VFE0_BASE + 0x04cU, 0x00000000U);
cam_w32(cam->camss_base, VFE0_BASE + 0x6fcU, 0x00000000U);
@@ -689,9 +762,16 @@ static int msm8905_cam_enum_frameintervals(struct file *file, void *priv,
static int msm8905_cam_enum_input(struct file *file, void *priv,
struct v4l2_input *inp)
{
struct msm8905_cam_dev *cam = video_drvdata(file);
if (inp->index > 0)
return -EINVAL;
strscpy(inp->name, "GC2395 Rear Camera", sizeof(inp->name));
if (cam->chip_id == GC2385_CHIP_ID)
strscpy(inp->name, "GC2385 Rear Camera", sizeof(inp->name));
else if (cam->chip_id == GC2365_CHIP_ID)
strscpy(inp->name, "GC2365 Rear Camera", sizeof(inp->name));
else
strscpy(inp->name, "GC2395 Rear Camera", sizeof(inp->name));
inp->type = V4L2_INPUT_TYPE_CAMERA;
return 0;
}
@@ -1017,7 +1097,7 @@ static int __init msm8905_cam_init(void)
goto err_v4l2;
g_cam = cam;
pr_info("msm8905-cam: registered /dev/video%d (GC2395 800x600 RGB24, dma=0x%08llx)\n",
pr_info("msm8905-cam: registered /dev/video%d (GC2395/GC2385 800x600 RGB24, dma=0x%08llx)\n",
cam->vdev.num, (unsigned long long)cam->raw_dma_phys);
return 0;
@@ -1071,6 +1151,6 @@ static void __exit msm8905_cam_exit(void)
module_init(msm8905_cam_init);
module_exit(msm8905_cam_exit);
MODULE_DESCRIPTION("Qualcomm MSM8905 / Nokia 8110 4G GC2395 V4L2 Camera Driver");
MODULE_DESCRIPTION("Qualcomm MSM8905 / Nokia 8110 4G GC2395/GC2385/GC2365 V4L2 Camera Driver");
MODULE_AUTHOR("Bananarchy Project");
MODULE_LICENSE("GPL");