|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- D8 s9 r5 p: g: L
#include <linux/init.h>$ w# O2 n' O! ]& ], @3 }2 w* @
#include <linux/module.h>
|7 Z a& k/ W- |6 f- X#include <linux/kernel.h>! U+ Z e# p8 P& c& H0 W0 N
#include <linux/types.h>0 b$ I$ m$ X3 g7 ^! {# P- T
#include <linux/gpio.h>" d; C5 G3 W# J, K; V; F" i
#include <linux/leds.h>3 k N* E! }& s: f& S) O7 o
#include <linux/platform_device.h>/ n. e! \ X9 [, h) U
9 }3 o$ c4 J4 _9 j$ Y
#include <asm/mach-types.h> w |2 x6 A! t5 j
#include <asm/mach/arch.h>
9 g- B* L0 E$ q1 @2 l3 H9 k#include <mach/da8xx.h>
9 m4 h0 a. d( r#include <mach/mux.h>5 U+ }& [6 I i
" D* D$ X [; O, a0 ~9 O. s+ j$ Q* y/ m#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 k% ^, ^( U( T5 w7 f( w1 v6 @4 _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ S! T1 x5 M0 P/ [$ m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: b9 o% \1 E# x" i0 Z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 P7 O, y; L& w
5 p0 C1 D9 n2 D3 Z/ Y% z
/* assign the tl som board LED-GPIOs*/
3 V) O. t! c! N; U- _3 }; Z' t5 Kstatic const short da850_evm_tl_user_led_pins[] = {
a7 M. H( n7 ^2 i# Q /* These pins are definition at <mach/mux.h> file */9 N$ g6 \( A% f$ J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; Q v- Y- L3 Z5 i7 v
-1
) ^8 t; W1 Z% C w* M};
: j l( O' r" m) H/ {$ B/ O3 @' A4 Y/ c& `$ }% i* k# l. C% D6 J
static struct gpio_led da850_evm_tl_leds[] = {
z. P; r% V% @3 G {# p9 U! b% c4 m: y3 i
.active_low = 0,
3 C% j$ o/ K% D6 t$ v7 j .gpio = DA850_USER_LED0,
! b# q* F9 P1 o5 m .name = "user_led0",
, v' p# c6 y$ O .default_trigger = "default-on", A- `% X+ O# J5 `
},
7 _9 j$ U& t; Z/ @0 Q: u { Y% v- H& P- A4 R) a& J8 {$ X- z. r
.active_low = 0,
9 D# x% d6 h/ i8 x0 K" c# ^ .gpio = DA850_USER_LED1,
: z9 U* Q% Y7 L, F% l .name = "user_led1",
4 H: p9 o/ p# }( L" c .default_trigger = "default-on",
3 j( N1 b- E/ t },
/ T4 q( C% @$ A* a9 @8 t1 ]" Z3 \% I {6 O) w$ H, y( }* n4 D
.active_low = 0,
2 k* t. G# j* y6 ?' W' i .gpio = DA850_USER_LED2,
- [9 K6 ]8 q, j; N .name = "user_led2",
* A5 |! I' M0 b1 W& m( z .default_trigger = "default-on",
/ U. I1 g) _5 R! z& Q7 W },$ O! m0 c% Y9 b# T4 Z/ \
{
! @' p# ^- u1 P$ z' h: J5 E .active_low = 0,
9 K/ w# S0 _8 ^' U5 n1 T .gpio = DA850_USER_LED3,
3 P% _8 M a. [- w% J .name = "user_led3",
5 x- D, K- \+ [' Y* X6 d* Q. Z .default_trigger = "default-on",
/ `4 v6 w: B2 S. H },% }( U ?0 S$ Y( U/ X& P
};2 o% @( J" V0 [- D2 J. j
7 V2 {/ `: R# N1 Dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! i3 M+ K- I! V6 v- G
.leds = da850_evm_tl_leds,- N/ T2 W( R4 ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. D: s( k3 T, O( g4 c+ c. ` F};' S0 y6 C, Q( C" u
1 P& r0 w7 u6 i0 i2 [' e" m
static void led_dev_release(struct device *dev)
4 I( R. e" w" H{
/ J6 s9 @& T+ z( x1 m, U: b};
5 k5 u- E6 I0 `% v! N" C7 [
& H# h6 e6 k4 P& Z6 Wstatic struct platform_device da850_evm_tl_leds_device = {
& L+ A3 H- C! I .name = "leds-gpio",/ ]$ U: S2 E5 w
.id = 1,4 A- U5 I; y/ `' G" |
.dev = {
) `- q. ]- n5 {- d3 J .platform_data = &da850_evm_tl_leds_pdata,! o2 P/ |6 }0 `7 N3 n, M1 H
.release = led_dev_release,
5 ~) f1 o, u* E }0 H8 j1 O5 p4 P3 P9 c; h
};' t. s) A. K, z/ z
9 Q/ I: r6 E% K* v
static int __init led_platform_init(void)9 [0 Q* O1 E, g* y3 j- N, n; S
{
: i# I& R9 A) Y9 ?0 }/ u% D$ { int ret;0 o2 P1 @- X& z) T% Y
#if 0; @0 i+ I7 D3 J Q2 w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- s' R9 H+ |( L+ f
if (ret)$ h7 F+ X& B* |
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 o8 I8 v/ E$ a7 t
"%d\n", ret);8 P+ }. @3 A& x! ?
#endif! `5 \, ?% [ ^0 t
ret = platform_device_register(&da850_evm_tl_leds_device);# V1 a( q! j: Z
if (ret)
+ ]8 i0 j. `! y4 m) \! C8 T! f: N pr_warning("Could not register som GPIO expander LEDS");0 u/ N! R. f: E4 V
else7 c8 D; _: _7 [4 d1 n5 ?* D
printk(KERN_INFO "LED register sucessful!\n");# a4 t n8 Y) T' @. F) W, m
3 {' c" {# n+ T
return ret;" W* t- _" O$ F* F
}6 y1 l* _5 S: i: h& f" j
- J5 \, ^% n) a3 X3 v" v, l ?static void __exit led_platform_exit(void)6 A* F! \5 |9 b+ h5 v$ d
{
( M! {, l- Y4 Z" { platform_device_unregister(&da850_evm_tl_leds_device);$ k8 f. x) U8 {8 d: I. Y( i1 e
0 A* c* E" N8 x: k, C% p$ @- @
printk(KERN_INFO "LED unregister!\n");
# p- d P3 G2 L5 B; Y1 u. {}
1 d. Y0 M3 O. W7 t' _2 L; F4 a* O& ? v6 I7 I, Q$ ]3 q, p
module_init(led_platform_init);
& W" C R- e; h1 a2 A7 p5 jmodule_exit(led_platform_exit);
$ Y7 r# q0 E; L9 ~) ~2 H K5 b1 B$ T1 U0 g' J$ ?2 w+ x9 J
MODULE_DESCRIPTION("Led platform driver");
( ^* ~* i! B# B5 v* o$ t1 ~MODULE_AUTHOR("Tronlong");
* E1 R! X' m7 H$ XMODULE_LICENSE("GPL");$ I% A! {5 W: O: V& z
, f0 |1 N- W+ y/ Y W0 _
|
|