|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# u! c( O! X; P' z; m
#include <linux/init.h>& D6 V1 A+ C/ D; p4 E& \( Z! X
#include <linux/module.h>* w% G5 G9 K* q7 x$ [
#include <linux/kernel.h>
0 q; h; A1 U9 z#include <linux/types.h>
1 K4 Y. J' X8 D8 c#include <linux/gpio.h>
4 Q3 N6 X% P( U0 {0 W#include <linux/leds.h>
# [ Y5 s* a% {# {: A4 A1 X#include <linux/platform_device.h>
. L- P/ n' w7 U- j
1 f$ j+ H! [5 ~3 {#include <asm/mach-types.h>6 \$ x1 n' `7 }
#include <asm/mach/arch.h>3 m/ k/ ?0 V( Y" n' R
#include <mach/da8xx.h>
! [0 V* @. ?; `. n#include <mach/mux.h>8 c0 p0 ~" k! Q" p* d0 j s( x
; R* K8 D5 N( Y' r1 @
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! S5 _3 E6 t0 Z5 E; _+ X9 X1 N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 e( K* s6 n0 h* G5 g; q" u" ]# `
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 g2 T4 S) M: N) ^) m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ d6 b8 {4 d6 S6 h4 I. W5 o9 P" d/ B- y% E+ R
/* assign the tl som board LED-GPIOs*/
9 x. C1 E/ \7 g, gstatic const short da850_evm_tl_user_led_pins[] = {
1 S9 c5 Z1 F* C /* These pins are definition at <mach/mux.h> file */
% q d- g: X7 C G0 u1 n' S DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 H, t- M" F/ k+ V -1
2 s2 ] B! \2 M4 V, s/ m};4 b R8 ^: |6 l/ f! N
; a1 n2 w. K8 {9 Vstatic struct gpio_led da850_evm_tl_leds[] = {/ T$ {3 ~3 R7 j _+ E: G$ _% J) x
{
+ C, _% V7 Z4 c# V: n% \" t- G .active_low = 0,9 v) S6 X# |% i3 @3 B# D, H7 O, b
.gpio = DA850_USER_LED0,9 ` c5 {$ L6 h7 C4 S$ R( e
.name = "user_led0",6 w2 W% D9 t1 O
.default_trigger = "default-on",
/ K( N0 i1 Q' T5 ]( s) H },
9 N: D8 |7 o# K* C {6 F, ~, W {) F: g6 r
.active_low = 0,1 A# D8 _0 J3 d$ W* B7 F5 G5 t
.gpio = DA850_USER_LED1,; V8 P- A5 J% b( E* N
.name = "user_led1",. t- H5 N1 Y, D2 |7 R
.default_trigger = "default-on",
4 U3 f+ ]' Y ~/ L3 @# J& U },
: t$ ?7 [2 T% J# u {
! [% H; _9 ? S/ V5 A2 o .active_low = 0,
- @4 | j( S7 q8 l: V8 l .gpio = DA850_USER_LED2,
# S* z) X- T, s+ ? .name = "user_led2",$ ^; U, c' n. `5 |: s' T9 K
.default_trigger = "default-on", t: x1 q( \; o& S+ [7 M/ n' L. M
},
- }& ], O5 r7 q0 ?" f' } {
0 j; Y" c" B) ^' {( | .active_low = 0,
- n2 ?9 g9 C M/ w; S .gpio = DA850_USER_LED3,: F H5 y: j6 g% ?) z
.name = "user_led3",
G' f: k! Y" A) K3 M- v# z: s .default_trigger = "default-on",
* Q1 z Q3 @4 _7 l: G1 u },
4 n# V6 O2 |& A8 k; g};
' p: P# c% {, x4 m$ I9 {" d$ {0 z1 z9 j" r" ^3 X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ T% g/ q' L1 D: p .leds = da850_evm_tl_leds,9 ?% y7 c$ R n& O8 x# S
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" P& A9 S$ G' \5 L};- D0 P- C% |( E; w: X: O6 `9 V# {0 J
: b; w- I6 b2 \$ R8 S; o
static void led_dev_release(struct device *dev)
( y4 D$ D, g3 z{
+ y o3 \2 z; W3 b- ]3 w};! _: a% U* {+ @3 y1 \( t# K
( q3 H+ w' U! G+ i% t( _8 I) q
static struct platform_device da850_evm_tl_leds_device = {- t' Z( b3 _4 l1 m6 o( I
.name = "leds-gpio",9 V% j' X* { e: s! e
.id = 1,
, g- H) |& V+ \9 \ .dev = {
/ l- i7 D2 u7 C- E1 T Y& u .platform_data = &da850_evm_tl_leds_pdata,
' g4 k$ Z- O. ]# H, S' d .release = led_dev_release,, G9 _7 ?3 ^6 z( J2 w0 N
}
+ r" J o6 C: S, X$ a};1 N! A5 A* w4 R" a* j5 b
4 [; ]3 A. ]+ f/ m8 a
static int __init led_platform_init(void)" t7 r! o5 C0 t0 c# p: }
{, l( }! r: e7 ]5 Z8 n* F
int ret;
/ h/ ? T! p2 a, {& K#if 0
" ^' y) }5 n+ ?% n/ k ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- n% a# |! T- ?# N
if (ret)4 g- H+ k. h5 B' T$ S8 I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 t: L4 K1 w) [/ g& j: M" n "%d\n", ret);' l- N- J' B- X6 Y% b
#endif* ~! D- p& {, B/ k# v. _2 ]' H. A X
ret = platform_device_register(&da850_evm_tl_leds_device);! ^' B2 I6 n8 [2 W1 u
if (ret). a" |5 u6 \4 q7 @
pr_warning("Could not register som GPIO expander LEDS");8 r/ N, y4 P! ] J1 r6 i
else2 [2 ~, q0 c$ x% }8 f
printk(KERN_INFO "LED register sucessful!\n");
$ d, }5 t+ @5 j3 k2 t8 K# ^$ W0 E5 Z- o( x( w* Y9 T
return ret;
& y* D# j; m ?6 Z! _}: l5 u, K7 ?4 r6 u# m K7 T- \
6 Q4 U6 c/ T, T& V
static void __exit led_platform_exit(void), z2 z, m5 H' W" l6 Q* D7 V
{0 {, s5 f/ P9 T% t1 L! s
platform_device_unregister(&da850_evm_tl_leds_device);
+ ]" c4 C8 ^6 F9 H) {- a( h3 `
" A) G* e( t5 \) }/ c; R printk(KERN_INFO "LED unregister!\n");
6 K, B1 U. V. }: S l* f3 [, |}& w& c' g- M z2 M
5 x" F! u% s: U9 d6 {) h
module_init(led_platform_init);- `1 t7 b& s4 j" n! I& v
module_exit(led_platform_exit);
) q8 I7 Z' B7 y2 K% t" E) X% v7 a0 O/ h j$ e# ?
MODULE_DESCRIPTION("Led platform driver");/ F* u3 w0 t( ~' b' v0 o: J
MODULE_AUTHOR("Tronlong");
' A8 i& ^+ S: k: F6 e( X$ NMODULE_LICENSE("GPL");
2 y' u o8 O6 W; K" p) m3 [; a6 b6 P( x
) M1 `. r8 s+ |; S |
|