|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 J% G' X4 G8 t! H- W) H0 N2 W
#include <linux/init.h>
, ~. ]; e0 v: V9 E/ @#include <linux/module.h>& ?1 x2 f+ l+ {- \! M4 ~9 o) Q
#include <linux/kernel.h>/ \& {( R% n. l- a& b' F
#include <linux/types.h>: s( b. c: v- l8 A. y: r! z, `
#include <linux/gpio.h>
% K: _6 x% M" L; d' B8 @+ z#include <linux/leds.h>5 Z$ w9 V0 F3 Z$ o
#include <linux/platform_device.h>" X6 r9 @9 m: P$ p" c& N
. i$ W; Y+ n, [
#include <asm/mach-types.h>2 w" T. W' H. ?% A0 p
#include <asm/mach/arch.h>
2 ?7 w+ i9 e* {$ M2 s#include <mach/da8xx.h>
: E9 A, W7 K+ K" s* P#include <mach/mux.h>
3 p' j' Y$ i" _% ~ m9 Q+ _
% o6 Q# f: F' [6 W1 K8 i#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ r6 S# Q8 i m9 S#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ K5 x& U: S* a, O5 f1 }% H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). c' n8 N1 f) Z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 e. E7 h% }: |0 W. k7 Q2 `
* ~# w) V" {5 G6 q/* assign the tl som board LED-GPIOs*/" O3 v& o; a% O" z
static const short da850_evm_tl_user_led_pins[] = {" C3 I h& w: M \
/* These pins are definition at <mach/mux.h> file */. V3 H, N" X8 f% L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ B; h3 j$ x( d9 V" }% _ -15 _; ]+ b+ e6 S" _- G
};- n1 V% R. q) q
6 L1 T: i _% ]# n4 _' Zstatic struct gpio_led da850_evm_tl_leds[] = {
4 }% i' }( i, q0 { {
9 R2 t1 c( N* @! D7 V. R" n, S .active_low = 0,
$ q/ s; o' Z& Z7 ?2 F .gpio = DA850_USER_LED0,- z1 x, b! k; o; g
.name = "user_led0",
6 Q, L1 J: f( K3 O1 ?- D+ C1 M' E .default_trigger = "default-on",1 w# }1 } x6 \6 W: h
},5 g* a0 ^% R; y- O. a' _+ Z# W8 R
{- B6 o2 Y5 O2 G `
.active_low = 0,
1 ~; h* t! p+ M6 `; b% q! E .gpio = DA850_USER_LED1,
7 M: l) x4 J3 k0 Q .name = "user_led1",
2 i* ]9 @9 L: m .default_trigger = "default-on",; j- n u3 H" K% ?* F8 Z* k" P
},
. b+ Z j$ @& X/ p# a8 l {
* W1 ], u' y; [/ [) @# {7 R .active_low = 0,
+ K3 `) }8 W8 J$ J .gpio = DA850_USER_LED2,
& s' ^! s3 S8 d) L .name = "user_led2",7 n8 H. |$ F( V, }+ _# A' U% e3 f
.default_trigger = "default-on",' h9 k& M# k8 u
}," U6 u* C2 s, X$ D) f7 d# u
{6 C( ]! ^$ k+ } v3 O4 L l
.active_low = 0,4 |: b) \; a9 p6 N2 M. V* P
.gpio = DA850_USER_LED3,
# A5 f/ n3 A/ I2 o8 n' G: x .name = "user_led3",
' p; _4 F+ c9 o) h4 D .default_trigger = "default-on",
! N8 R7 z0 M- Z: r) {" @ },
S9 p- v/ U: o1 n9 B( _};; y% @! G- k) [# P+ V4 C
: _' G% Y3 s" ~3 m- @6 N* Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( f- Y) e- d- U' h+ W u .leds = da850_evm_tl_leds,
0 B* X0 o: ~, S9 [4 u .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ n% L2 i* L% q3 \};
7 E, A+ m2 e# n4 u; q! U0 d- Y# x& y# o; Y& }
static void led_dev_release(struct device *dev)
/ Z# F5 p- B( A, h) x{
l0 O, y, G8 Y};% C5 F$ V1 i# n
, p6 w+ B( \ n; t
static struct platform_device da850_evm_tl_leds_device = {
1 H- ^$ }# ]( l% q3 ] .name = "leds-gpio",; g$ Z; u% M9 }$ r
.id = 1,
1 q" V$ ^4 n" H8 V+ Q .dev = {
9 a# P1 `. e8 @% V% m" E .platform_data = &da850_evm_tl_leds_pdata,
) {3 N0 i% e) L+ m$ y5 ~* q .release = led_dev_release,
/ u& S8 x, x: w- m ? }0 w( {' m9 I) g% e
};
9 Z0 i5 k# n ]) u! h( B) K8 K7 k+ \- @
static int __init led_platform_init(void)
( n8 F5 N( r- x{$ i; |4 s3 @6 b; q! c6 R
int ret;* b: q/ \2 T3 V |3 t, ]2 R" o
#if 0
! C& `$ B1 _. ~# n ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* I9 x3 t! G8 R3 |% B
if (ret)
- B( s& W' {+ n" f P7 q/ | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' s+ h3 @! n. d+ G5 C0 D- _
"%d\n", ret);6 W% _# ~6 ]! A1 B( B: q1 |
#endif
( ~! }8 X9 g; V3 [; \( T, L# L ret = platform_device_register(&da850_evm_tl_leds_device);
: D+ d0 |' p# X2 G# k0 N if (ret), b% Y% @$ \, Y7 A3 n
pr_warning("Could not register som GPIO expander LEDS");
: `3 P. e2 A, _7 V4 s else
$ N( U; r- d. q% j7 }# V printk(KERN_INFO "LED register sucessful!\n");
M2 _; J0 c {" P; l# G3 H6 w: R0 L3 X$ j7 A
return ret;1 K, X+ T: Q" K" L% f; j+ T3 I
}
# S3 L5 X: L6 {- m0 E
7 S% H+ ?, b- nstatic void __exit led_platform_exit(void)
$ ?0 Q8 [! ^( i1 E5 k% A{" l5 ]" k g5 ^. O& A9 W
platform_device_unregister(&da850_evm_tl_leds_device);
6 N: Z( E% e P' N4 V) U- x' }5 U; f1 u4 n8 Q( s
printk(KERN_INFO "LED unregister!\n");& h6 ?4 t$ k4 N& S# H# H5 ]1 f
}9 b; a1 @+ h' q9 @$ ]3 G
/ K! B3 J' z( @- g1 w8 V- L
module_init(led_platform_init);( [; }8 r" G+ W9 B
module_exit(led_platform_exit);6 W7 E3 \! O9 x: `
% c! c- N3 k- G1 Y* j) z
MODULE_DESCRIPTION("Led platform driver");
* v. C0 B, r" A% P5 _7 s# w+ xMODULE_AUTHOR("Tronlong");- ? u" l# N' ?+ n% H
MODULE_LICENSE("GPL");) B) O/ W( Z: i. \
- [9 Y6 B: B5 K |
|