|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% }$ q( |) y$ e H% {! o( w#include <linux/init.h>& V6 \5 O2 [7 F
#include <linux/module.h>! j* V) E1 A9 b0 l
#include <linux/kernel.h>. x% S! B1 H$ O h5 H
#include <linux/types.h>3 v$ f$ J: `$ _
#include <linux/gpio.h>, P$ A0 m/ x! @3 _! _$ z' @) j
#include <linux/leds.h>' n6 Q7 e/ h" y& H1 ^: k
#include <linux/platform_device.h>
$ ^+ l; L, \+ D1 R! a7 B, @# J# S3 E0 ]- S% t z8 \
#include <asm/mach-types.h>" E4 L1 {+ V5 Z0 [' B: Q5 u
#include <asm/mach/arch.h>/ g; ^4 k( l, u: L" a2 @6 `
#include <mach/da8xx.h>
2 a7 f, T: O9 f# J3 |' w4 B#include <mach/mux.h>
+ k3 s9 \4 \: g2 k8 F1 ?+ [1 B K; K9 F8 w! n* s. v
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" `! Q" \7 B) B& Z' h
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ K; o [; s4 p2 g
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% E0 |; Z% E' U1 y4 Y) u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" L0 j" q# y O; y3 i+ f
0 Q. x, y" f8 K, B; q/* assign the tl som board LED-GPIOs*/; ~6 n& C j$ ?
static const short da850_evm_tl_user_led_pins[] = {
$ _) U) U- Q' G( U" D /* These pins are definition at <mach/mux.h> file */
4 S) U+ S" f' k" k, U) E- b3 L: ?7 P V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 q0 ]5 l8 ]; e1 O' W9 p -13 W c; n( `6 s9 k, z f& _; [
};: ~, ]5 q0 c5 f h: y' c# H: k9 F
" Z2 ~) S% M# v
static struct gpio_led da850_evm_tl_leds[] = { Z. V' g7 k" A8 A
{
: u- r1 Q3 C$ a! T `6 I1 n .active_low = 0,, \9 b9 s% u- J8 L* I6 l, g
.gpio = DA850_USER_LED0,5 j2 j) c! Q6 n( P& h
.name = "user_led0",
* ^; w8 Z4 Y$ @5 ]/ v6 H2 [2 M5 r .default_trigger = "default-on",
% f; O* ?% s$ y },
/ N& V# P" B0 } }. ~% Q {: ^5 ` h9 i( z5 V/ C( H9 x; \2 O- G
.active_low = 0,. i) e3 k9 r) z# u! p) b2 R
.gpio = DA850_USER_LED1,
- h$ z* n! l5 k8 l G .name = "user_led1",
" j& L) f0 L3 w# ]7 j' U .default_trigger = "default-on"," f8 h3 C( J0 X5 m
},
- }4 n, v3 e& [- t. n. I' D {6 M9 X. |7 e$ }1 ~# @& q
.active_low = 0,0 |& P+ t& g: F5 a3 ]
.gpio = DA850_USER_LED2,
) Y# c! a3 I# y- i8 n/ E) b: Y; i Z) T .name = "user_led2",
6 S% l ?7 W3 ~- ] t .default_trigger = "default-on",% e3 Q) s9 o5 p& G0 j) ^
},
2 F. l4 q; K0 C V {
7 X4 F8 c$ L! ^" {0 L+ l .active_low = 0,
) R2 l; R- O5 g8 C7 z& {% T9 p .gpio = DA850_USER_LED3,
# A# E1 J, p, v2 | .name = "user_led3",
/ m4 V' r$ h$ e( f I/ l .default_trigger = "default-on",
! r- L7 q+ H6 d3 D& T0 f },6 D- R7 n L/ b8 c) m! c
};2 y. G, j8 n: \. p/ R
# i- r. |" N' P! E' `5 V$ t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# q8 n9 ` c( E" m7 n .leds = da850_evm_tl_leds,
! d* j( Q- K6 \$ k7 w+ Z/ D6 B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. e5 y: N c$ B+ R. c/ T' V7 u/ X* j};* `! j* X4 g' |: z5 i
) V0 d" z' t! F: ~static void led_dev_release(struct device *dev)
* _6 x# p% j |0 E2 k2 u$ @{
" F8 E8 m4 d. H$ t! q7 z};& x- h) F3 S7 x0 H5 t
3 w- p# u0 _" D5 n5 x2 x! a0 e3 A
static struct platform_device da850_evm_tl_leds_device = {
; I: n0 c, c7 r% t+ j .name = "leds-gpio", ?) W3 l* b( G/ A* T% H. H9 H7 l0 v' \: h
.id = 1,
% E; i( M! E" ^. m+ f' G0 p' ?& T* Y .dev = {
4 U9 f" I! `( X4 l! E- b6 L .platform_data = &da850_evm_tl_leds_pdata,1 y: M9 x Q3 P/ R9 n
.release = led_dev_release,
6 o2 D/ F: a- e9 q. p }
; x K& P" K3 \};
1 M) k! n* P+ S, A2 ?. n& q" Y) X. [
: L9 o9 e# y1 Y9 E. s# ostatic int __init led_platform_init(void)) e7 I8 E3 O( J9 M" X
{
- A8 U: q; a& }( L int ret;
- k! d9 }. A0 _% R% p- t& a#if 0
4 } Z/ y5 ] M ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; j" S8 N6 X( ?4 n. o
if (ret)- U& q# j0 H5 g/ @" N6 x, j! _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( o5 h: Z6 F5 Q6 X: G
"%d\n", ret);; A: v2 ~: C$ a5 v
#endif/ t' K- j% O n) ]- n
ret = platform_device_register(&da850_evm_tl_leds_device);
4 `7 U" p; K6 B! x$ U! P/ P if (ret)
W& P' \6 Q- a+ o( D pr_warning("Could not register som GPIO expander LEDS");
( U" M0 p. [! {" Z! _3 T else7 q* U6 ? N, |/ z9 d
printk(KERN_INFO "LED register sucessful!\n");) n p& f/ j( {' u7 W N5 h
0 {4 @7 a. q! A% D" N
return ret;
2 z5 m, A0 Q6 ~}7 J- k& g; R+ ~! Z, i) Y
% s- _& s: |# F% P. K6 m
static void __exit led_platform_exit(void)
4 O2 A" N- C6 k+ c5 i4 {{
) ?& S8 J) l) Q1 b" G platform_device_unregister(&da850_evm_tl_leds_device);! Q8 X) @. d( D' J0 D @
5 U R% l1 p B, q printk(KERN_INFO "LED unregister!\n");
0 ^; g( `6 _$ q) V}
7 v c5 T7 A- ]4 v
* u; G* w+ J" o# Tmodule_init(led_platform_init);- x; p! M+ R; {" S
module_exit(led_platform_exit);
; b# d* \! u' ]6 B/ z: s/ h/ i0 G( L3 N. B* s5 O
MODULE_DESCRIPTION("Led platform driver");
0 i7 G1 n9 d9 Q: E/ AMODULE_AUTHOR("Tronlong");6 }' H2 G! Y1 l# a ^0 T8 V+ S
MODULE_LICENSE("GPL");, o! y( r) \ c/ V: F# W9 T% M
* H- A' b5 a: T' o
|
|