|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& Y4 _1 u: N/ h. @) {
#include <linux/init.h>6 B/ r5 ]5 S6 f
#include <linux/module.h>
! |- z+ _% i c1 b$ Q#include <linux/kernel.h>
/ A$ n+ b, I$ f o3 |#include <linux/types.h>" L5 v5 @4 J/ O( s3 U
#include <linux/gpio.h>
' O. A0 Y. L ?: s) ?#include <linux/leds.h>9 W$ s+ w/ V% @ L! w, j: ~; q) j
#include <linux/platform_device.h>( N. ^7 g9 g6 e0 Y; ?- S2 P
) O/ F' G4 B7 }& e#include <asm/mach-types.h>
& d9 Z7 `1 t! f6 u; F* B0 d#include <asm/mach/arch.h>
3 r/ T$ B s- G! \4 C3 a$ f& v& i$ X#include <mach/da8xx.h>
8 x5 R8 ?/ o5 k7 N, a#include <mach/mux.h>) }) j; Q9 a0 G9 E; U
8 J9 Y% {/ o }" [' W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 p* H; R3 r. ~& D# z- t7 }+ t. G; A3 r. M
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) F0 H7 o$ v# S& M: O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ h2 g7 j- l; U. v5 ?0 W/ [#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): z- Q3 _; D# j9 D+ U7 v
& K6 F, s7 w# F+ Y0 m' H3 n/* assign the tl som board LED-GPIOs*/$ q6 W8 x6 z0 V4 a# L; G
static const short da850_evm_tl_user_led_pins[] = {
; d: b3 V% D9 \4 {8 {7 I7 D0 w /* These pins are definition at <mach/mux.h> file */
2 X9 D% \# `5 I9 k. B" y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 \5 u. H/ q. ~' }$ J
-1
! m4 i8 ~; ?0 l0 V( f: n$ A. K};( e4 `# E, F6 F2 o, `; i( A
( V' q1 }& F+ sstatic struct gpio_led da850_evm_tl_leds[] = {
0 n7 |, Q O# e% v; [9 m1 A {2 m0 C% W- H9 h5 Q+ ~; i/ u! J
.active_low = 0,
$ s) X; Y$ ^4 e6 D# B .gpio = DA850_USER_LED0,
2 z) a$ ^, I1 v& w' Z .name = "user_led0",
) T$ e% S$ D [9 v$ Z; Q6 @2 r .default_trigger = "default-on",
, f+ Y7 ~$ i0 S% t7 M/ D o },
" o( ~) M# |" m: W. {. T: X {: H* H7 o+ o9 B2 @3 o: m6 u; F' z
.active_low = 0,
7 ?6 E9 F4 D9 r+ y$ Z& @% K# P .gpio = DA850_USER_LED1,4 Q2 w6 }9 l; h5 o) w
.name = "user_led1",
, i- i2 C& f0 f: T n! H* Y% p .default_trigger = "default-on",
. E, l9 }) x" T$ X6 L9 s },- I5 k, L" ?# a% g
{2 }) ~" j7 s3 _" ?
.active_low = 0,
: t/ @' i! C+ w .gpio = DA850_USER_LED2,4 ^+ K9 T/ L+ l. A8 w
.name = "user_led2"," U5 w" o4 z8 R* }2 N$ D
.default_trigger = "default-on",
( Q$ P6 l4 @2 U" w, ~+ e+ n },0 p' q: V8 b3 _: S) k4 s
{
3 f, I N2 q2 g- k" d% k: d .active_low = 0,
+ P$ J# B) u0 X9 @ .gpio = DA850_USER_LED3,( A, {0 s0 X) j5 Y" w9 ^7 s
.name = "user_led3",! a7 S/ g* I" ^3 ?5 C
.default_trigger = "default-on",
% v9 {( \7 \ ]$ _ q% I' Y" {8 X },7 Y) ?# p2 y8 r0 x+ g5 T
};/ s+ o- a7 e* m) O& N0 B
7 s- _, F! j: P7 }- Zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- p1 ^6 Y: J: F9 P- F! N .leds = da850_evm_tl_leds,
% R/ y. g- }8 Z) D6 U9 I7 k y! f6 _ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 l9 s- x1 D- J" i' z, N};6 {8 l- U: D; j! n% m
3 b! v/ K; J* |9 H9 Hstatic void led_dev_release(struct device *dev)" @& m y1 t% l Z6 ]: @
{
9 s1 ?) u+ B& g& ]) r* d% O$ E};# j- M b( ~3 Z" e' [6 Q1 A% U5 Z
+ ` R( i) N- p
static struct platform_device da850_evm_tl_leds_device = {
9 h" F# ?, f/ z0 R .name = "leds-gpio",
: p$ p C' J' I" ?+ z& j4 t .id = 1,
v5 P3 _8 b% E" ~ p* } .dev = {' c* ~9 n5 I( I) N% T1 g, z
.platform_data = &da850_evm_tl_leds_pdata,
# e4 t, K! N0 B* f .release = led_dev_release,5 C/ |% U$ J2 Y; _/ |6 D* ]6 f
}( }* Z! z4 t0 D) {; @6 w
};
2 y: u& _5 P% g( L3 k% H; ], ^( O" G* j6 `5 F' t5 `
static int __init led_platform_init(void)
9 P L& v! E. `) D{& ^8 e0 M; o* T7 G
int ret;
' P' {2 t5 f9 \* U4 J g# F#if 0
8 e2 e! d5 {) P0 p0 \+ |0 c, I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* ~+ D8 x' D+ [9 r
if (ret)
; N: @8 w( `& e* P0 ` pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 H! S) ?: ] @) k "%d\n", ret);, H j; h/ ~1 }2 Q
#endif7 \2 T% M7 x; ~& x6 K& R5 k
ret = platform_device_register(&da850_evm_tl_leds_device);
# [: e$ T. F3 ]( W7 l3 D if (ret)/ ^3 y4 [. c7 C. H6 x
pr_warning("Could not register som GPIO expander LEDS");0 i9 | ~& ?! h
else
3 m/ L! q8 x" _1 D2 C printk(KERN_INFO "LED register sucessful!\n");9 J' \$ o r1 {, H7 o! B
2 P6 @- }+ ]. ?. U
return ret;
5 w6 |( K: f8 y) j6 L9 e}. o; S/ ?, j) h5 A
! U5 l, M' f( Q' ^
static void __exit led_platform_exit(void) V& P$ v6 t `/ Z
{: k! n6 \& ^ c$ u3 N9 F- H
platform_device_unregister(&da850_evm_tl_leds_device);8 ?7 f, P% w* i5 o! D- a; q% N" z
. s- j |+ \1 t% N8 L printk(KERN_INFO "LED unregister!\n");
+ U3 Q" R) V7 e0 t- c; V% M}
6 d6 b6 ~) o( L6 h0 w8 n0 B+ }, z" T' s4 Z7 u- I- ~- O3 M3 k! Y
module_init(led_platform_init);
6 Y+ Q, X" ^ r4 Cmodule_exit(led_platform_exit);
! @. S2 C& |& E7 ?
. A# [# H0 o* K; t& P: }+ aMODULE_DESCRIPTION("Led platform driver");
: C" n9 k4 N% A0 f% e9 Y5 l( ^MODULE_AUTHOR("Tronlong");
0 t7 [5 P Q; p' oMODULE_LICENSE("GPL");5 {- p; B9 e! H, p9 r
. R U \# t- E! V: Q" g6 c0 ~
|
|